結果

問題 No.429 CupShuffle
ユーザー btk
提出日時 2016-10-02 22:40:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 1,664 ms
コンパイル使用メモリ 171,380 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 13:20:32
合計ジャッジ時間 2,564 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
    
int main(){
    int N,K,X;
    cin>>N>>K>>X;
    vector<int> A,B;
    vector<int> s(N),c(N);
    iota(s.begin(),s.end(),1);
    
    
    for(int i=0;i<X-1;i++){
        int a,b;cin>>a>>b;
        swap(s[a-1],s[b-1]);
    }
    string t1,t2;cin>>t1>>t2;
    for(int i=X;i<K;i++){
        int a,b;
        cin>>a>>b;
        A.push_back(a-1);
        B.push_back(b-1);
    }
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    int z=A.size();
    
    for(auto &it:c)cin>>it;
    for(int i=0;i<z;i++)
        swap(c[A[i]],c[B[i]]);
    vector<int> res;
    for(int i=0;i<N;i++){
        if(s[i]!=c[i])res.push_back(i+1);
    }
    cout<<res[0]<<" "<<res[1]<<endl;
    return 0;
}
0