Submission #63261743


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#define ALL(v) v.begin(),v.end()
#define For(i,_) for(int i=0,i##end=_;i<i##end;++i) // [0,_)
#define FOR(i,_,__) for(int i=_,i##end=__;i<i##end;++i) // [_,__)
#define Rep(i,_) for(int i=(_)-1;i>=0;--i) // [0,_)
#define REP(i,_,__) for(int i=(__)-1,i##end=_;i>=i##end;--i) // [_,__)
typedef long long ll;
typedef unsigned long long ull;
#define V vector
#define pb push_back
#define pf push_front
#define qb pop_back
#define qf pop_front
#define eb emplace_back
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
#define fi first
#define se second
const int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}},inf=0x3f3f3f3f,mod=1e9+7;
const ll infl=0x3f3f3f3f3f3f3f3fll;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
int init=[](){return cin.tie(nullptr)->sync_with_stdio(false),0;}();
int main(){
    int t_case=1;
    //scanf("%d",&t_case);
    while(t_case--){
        int n,q;
        scanf("%d%d",&n,&q);
        V<int>fa(n),id(n),rev(n);
        For(i,n)fa[i]=id[i]=rev[i]=i;
        while(q--){
            int op,x,y;
            scanf("%d%d",&op,&x),--x;
            if(op<3){
                scanf("%d",&y),--y;
                if(op&1)fa[x]=rev[y];
                else{
                    x=rev[x],y=rev[y];
                    swap(id[x],id[y]);
                    rev[id[x]]=x,rev[id[y]]=y;
                }
            }
            else{
                printf("%d\n",id[fa[x]]+1);
            }
        }
    }
    return 0;
}

Submission Info

Submission Time
Task D - Pigeon Swap
User zzr
Language C++ 20 (gcc 12.2)
Score 350
Code Size 1693 Byte
Status AC
Exec Time 128 ms
Memory 15240 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         scanf("%d%d",&n,&q);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:36:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |             scanf("%d%d",&op,&x),--x;
      |             ~~~~~^~~~~~~~~~~~~~~
Main.cpp:38:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |                 scanf("%d",&y),--y;
      |                 ~~~~~^~~~~~~~~

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 3712 KiB
00_sample_01.txt AC 1 ms 3816 KiB
00_sample_02.txt AC 1 ms 3680 KiB
01_random_03.txt AC 128 ms 15236 KiB
01_random_04.txt AC 127 ms 15144 KiB
01_random_05.txt AC 127 ms 15128 KiB
01_random_06.txt AC 128 ms 15144 KiB
01_random_07.txt AC 8 ms 10936 KiB
01_random_08.txt AC 67 ms 10920 KiB
01_random_09.txt AC 64 ms 15148 KiB
01_random_10.txt AC 75 ms 15104 KiB
01_random_11.txt AC 87 ms 15240 KiB
01_random_12.txt AC 51 ms 15132 KiB
01_random_13.txt AC 99 ms 15124 KiB
01_random_14.txt AC 73 ms 15008 KiB
01_random_15.txt AC 50 ms 15240 KiB
01_random_16.txt AC 111 ms 15004 KiB
01_random_17.txt AC 93 ms 15160 KiB
01_random_18.txt AC 65 ms 15132 KiB
01_random_19.txt AC 83 ms 15004 KiB
01_random_20.txt AC 72 ms 15128 KiB
01_random_21.txt AC 58 ms 15144 KiB
01_random_22.txt AC 97 ms 15108 KiB
01_random_23.txt AC 104 ms 15156 KiB
01_random_24.txt AC 99 ms 15100 KiB
01_random_25.txt AC 115 ms 15140 KiB
01_random_26.txt AC 109 ms 15132 KiB
01_random_27.txt AC 115 ms 15132 KiB
01_random_28.txt AC 126 ms 15148 KiB
01_random_29.txt AC 112 ms 15144 KiB
01_random_30.txt AC 38 ms 3916 KiB