Submission #63283478


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main() {
int n,q;
cin>>n>>q;
vector<int>pos(n+1);
vector<unordered_set<int> >nest(n+1);
for(int i=1;i<=n;i++){
pos[i]=i;
nest[i].insert(i);
}
while(q--){
int t;
cin>>t;
if(t==1){
int a,b;
cin>>a>>b;
nest[pos[a]].erase(a);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;

int main() {
    int n,q;
    cin>>n>>q;
    vector<int>pos(n+1);
    vector<unordered_set<int> >nest(n+1);
    for(int i=1;i<=n;i++){
        pos[i]=i;
        nest[i].insert(i);
    }
    while(q--){
        int t;
        cin>>t;
        if(t==1){
            int a,b;
            cin>>a>>b;
            nest[pos[a]].erase(a);
            nest[b].insert(a);
            pos[a]=b;
        }
		else if(t==2){
            int a,b;
            cin>>a>>b;
            swap(nest[a],nest[b]);
            for(int p:nest[a]){
                pos[p]=a;
            }
            for(int p:nest[b]){
                pos[p]=b;
            }
        }
		else if(t==3){
            int a;
            cin>>a;
            cout<<pos[a]<<endl;
        }
    }
    return 0;
}

Submission Info

Submission Time
Task D - Pigeon Swap
User ToT_and_QwQ
Language C++ 20 (gcc 12.2)
Score 0
Code Size 889 Byte
Status TLE
Exec Time 2222 ms
Memory 204196 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 350
Status
AC × 3
AC × 17
TLE × 14
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 3512 KB
00_sample_01.txt AC 1 ms 3552 KB
00_sample_02.txt AC 1 ms 3512 KB
01_random_03.txt AC 480 ms 202476 KB
01_random_04.txt AC 477 ms 202668 KB
01_random_05.txt AC 476 ms 202396 KB
01_random_06.txt AC 476 ms 202424 KB
01_random_07.txt AC 104 ms 132272 KB
01_random_08.txt AC 280 ms 131388 KB
01_random_09.txt TLE 2222 ms 204196 KB
01_random_10.txt TLE 2218 ms 204156 KB
01_random_11.txt TLE 2218 ms 204116 KB
01_random_12.txt TLE 2217 ms 202820 KB
01_random_13.txt TLE 2218 ms 202828 KB
01_random_14.txt TLE 2218 ms 202696 KB
01_random_15.txt TLE 2218 ms 202564 KB
01_random_16.txt AC 1137 ms 202504 KB
01_random_17.txt TLE 2218 ms 202740 KB
01_random_18.txt TLE 2218 ms 203544 KB
01_random_19.txt TLE 2218 ms 203496 KB
01_random_20.txt TLE 2218 ms 203716 KB
01_random_21.txt TLE 2218 ms 202836 KB
01_random_22.txt TLE 2218 ms 202660 KB
01_random_23.txt TLE 2218 ms 202652 KB
01_random_24.txt AC 457 ms 203424 KB
01_random_25.txt AC 511 ms 202496 KB
01_random_26.txt AC 495 ms 202400 KB
01_random_27.txt AC 546 ms 202572 KB
01_random_28.txt AC 493 ms 202472 KB
01_random_29.txt AC 514 ms 202504 KB
01_random_30.txt AC 216 ms 3704 KB


2025-04-15 (Tue)
12:45:01 +00:00