結果

問題 No.429 CupShuffle
ユーザー ngtkanangtkana
提出日時 2020-03-19 10:55:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,245 bytes
コンパイル時間 2,491 ms
コンパイル使用メモリ 206,208 KB
実行使用メモリ 7,132 KB
最終ジャッジ日時 2023-08-20 20:44:22
合計ジャッジ時間 3,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 30 ms
7,036 KB
testcase_12 AC 29 ms
7,132 KB
testcase_13 AC 30 ms
6,928 KB
testcase_14 AC 29 ms
6,924 KB
testcase_15 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,k,X;std::cin>>n>>k>>X;X--;
    std::vector<std::pair<lint,lint>>a,b;
    for(lint i=0;i<X;i++){
        lint x,y;std::cin>>x>>y;x--,y--;
        a.emplace_back(x,y);
    }
    char _;std::cin>>_>>_;
    for(lint i=0;i<k-X-1;i++){
        lint x,y;std::cin>>x>>y;x--,y--;
        b.emplace_back(x,y);
    }
    std::reverse(a.begin(),a.end());
    std::reverse(b.begin(),b.end());
    std::vector<lint>now(n);
    std::iota(now.begin(),now.end(),0ll);
    for(auto&&p:a)std::swap(now.at(p.first),now.at(p.second));
    {
        std::vector<lint>p(n);
        for(lint i=0;i<n;i++){
            std::cin>>p.at(i);
            p.at(i)--;
        }
        std::vector<lint>swp(n);
        for(lint i=0;i<n;i++){
            swp.at(i)=now.at(p.at(i));
        }
        now.swap(swp);
    }
    for(auto&&p:b)std::swap(now.at(p.first),now.at(p.second));
    lint x=-1,y=-1;
    for(lint i=0;i<n;i++){
        if(now.at(i)!=i){
            std::cout<<std::min(i,now.at(i))+1<<" "<<std::max(i,now.at(i))+1<<'\n';
            break;
        }
    }
}
0