Submission #63656221


Source Code Expand

#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;

int n, q;
std::vector<int> nestToIdx, lblToIdx, idxToLbl;
void solve(){
	cin >> n >> q;
	nestToIdx.resize(n+1);
	lblToIdx.resize(n+1);
	idxToLbl.resize(n+1);
	for(int i = 1; i <= n; i++){
		lblToIdx[i] = i;
		idxToLbl[i] = i;
		nestToIdx[i] = i;
	}
	for(int i = 0; i < q; i++){
		int type, a, b;
		cin >> type;
		if(type == 1){
			cin >> a >> b;
			nestToIdx[a] = b;
		}
		else if(type == 2){
			cin >> a >> b;
			int lb1 = a;
			int lb2 = b;
			int idx1 = lblToIdx[lb1];
			int idx2 = lblToIdx[lb2];
			idxToLbl[idx1] = b;
			idxToLbl[idx2] = a;
			swap(lblToIdx[lb1], lblToIdx[lb2]);
		}
		else{
			cin >> a;
			cout<< idxToLbl[nestToIdx[a]] << "\n";
		}
	}
}
 
int main(){
	int t = 1;
	//cin >> t;
	
	while(t--){
		solve();
	}
 
	return 0;
}

Submission Info

Submission Time
Task D - Pigeon Swap
User coperlm
Language C++ 20 (gcc 12.2)
Score 0
Code Size 864 Byte
Status WA
Exec Time 428 ms
Memory 14932 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 350
Status
AC × 3
AC × 23
WA × 8
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 12 ms 3632 KiB
00_sample_01.txt AC 1 ms 3512 KiB
00_sample_02.txt AC 2 ms 3592 KiB
01_random_03.txt WA 271 ms 14784 KiB
01_random_04.txt WA 269 ms 14856 KiB
01_random_05.txt WA 266 ms 14772 KiB
01_random_06.txt WA 269 ms 14760 KiB
01_random_07.txt WA 14 ms 10812 KiB
01_random_08.txt WA 153 ms 10812 KiB
01_random_09.txt AC 140 ms 14684 KiB
01_random_10.txt AC 192 ms 14688 KiB
01_random_11.txt AC 262 ms 14692 KiB
01_random_12.txt AC 134 ms 14700 KiB
01_random_13.txt AC 355 ms 14780 KiB
01_random_14.txt AC 226 ms 14760 KiB
01_random_15.txt AC 134 ms 14932 KiB
01_random_16.txt AC 414 ms 14764 KiB
01_random_17.txt AC 342 ms 14668 KiB
01_random_18.txt AC 140 ms 14732 KiB
01_random_19.txt AC 229 ms 14768 KiB
01_random_20.txt AC 173 ms 14688 KiB
01_random_21.txt AC 133 ms 14804 KiB
01_random_22.txt AC 345 ms 14764 KiB
01_random_23.txt AC 373 ms 14776 KiB
01_random_24.txt AC 297 ms 14764 KiB
01_random_25.txt AC 428 ms 14804 KiB
01_random_26.txt WA 389 ms 14848 KiB
01_random_27.txt AC 426 ms 14652 KiB
01_random_28.txt AC 280 ms 14760 KiB
01_random_29.txt WA 422 ms 14768 KiB
01_random_30.txt AC 214 ms 3548 KiB