Submission #63299010


Source Code Expand

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int n, q;
int a[1000010];
int b[1000010];
int c[1000010];

int main()
{
	cin >> n >> q;
	for (int i = 1; i <= n; i++)
		a[i] = b[i] = c[i] = i;
	while (q--)
	{
		int op;
		cin >> op;
		if (op == 1)
		{
			int x, y;
			cin >> x >> y;
			a[x] = c[y];
		}
		else if (op == 2)
		{
			int x, y;
			cin >> x >> y; 
			int cx = c[x];
			int cy = c[y];
			b[cx] = y; c[y] = cx;
			b[cy] = x; c[x] = cy;
		}
		else
		{
			int x; cin >> x;
			cout << b[a[x]] << endl;
		}
	}
	return 0;
}

Submission Info

Submission Time
Task D - Pigeon Swap
User ArmeriaLeap
Language C++ 20 (gcc 12.2)
Score 350
Code Size 599 Byte
Status AC
Exec Time 427 ms
Memory 15384 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 31
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3524 KiB
00_sample_01.txt AC 1 ms 3680 KiB
00_sample_02.txt AC 1 ms 3500 KiB
01_random_03.txt AC 287 ms 15244 KiB
01_random_04.txt AC 287 ms 15180 KiB
01_random_05.txt AC 285 ms 15320 KiB
01_random_06.txt AC 285 ms 15192 KiB
01_random_07.txt AC 14 ms 11124 KiB
01_random_08.txt AC 163 ms 10992 KiB
01_random_09.txt AC 143 ms 15228 KiB
01_random_10.txt AC 191 ms 15200 KiB
01_random_11.txt AC 260 ms 15324 KiB
01_random_12.txt AC 135 ms 15184 KiB
01_random_13.txt AC 350 ms 15244 KiB
01_random_14.txt AC 227 ms 15324 KiB
01_random_15.txt AC 135 ms 15384 KiB
01_random_16.txt AC 405 ms 15244 KiB
01_random_17.txt AC 339 ms 15196 KiB
01_random_18.txt AC 142 ms 15196 KiB
01_random_19.txt AC 231 ms 15200 KiB
01_random_20.txt AC 174 ms 15208 KiB
01_random_21.txt AC 134 ms 15232 KiB
01_random_22.txt AC 340 ms 15244 KiB
01_random_23.txt AC 367 ms 15240 KiB
01_random_24.txt AC 304 ms 15200 KiB
01_random_25.txt AC 422 ms 15228 KiB
01_random_26.txt AC 394 ms 15312 KiB
01_random_27.txt AC 427 ms 15248 KiB
01_random_28.txt AC 300 ms 15244 KiB
01_random_29.txt AC 422 ms 15312 KiB
01_random_30.txt AC 209 ms 3416 KiB