結果
| 問題 | No.429 CupShuffle | 
| コンテスト | |
| ユーザー |  ngtkana | 
| 提出日時 | 2020-03-19 10:55:45 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 31 ms / 2,000 ms | 
| コード長 | 1,245 bytes | 
| コンパイル時間 | 2,067 ms | 
| コンパイル使用メモリ | 200,844 KB | 
| 最終ジャッジ日時 | 2025-01-09 07:51:32 | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 | 
ソースコード
#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;
        }
    }
}
            
            
            
        