結果

問題 No.429 CupShuffle
ユーザー face4face4
提出日時 2018-05-14 09:49:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 73,568 KB
実行使用メモリ 4,900 KB
最終ジャッジ日時 2023-09-10 19:44:12
合計ジャッジ時間 2,467 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 78 ms
4,812 KB
testcase_12 AC 73 ms
4,560 KB
testcase_13 AC 79 ms
4,900 KB
testcase_14 AC 78 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stack>
using namespace std;

int before[100005];
int after[100005];
int n, k, x;

int main(){
cin>>n>>k>>x;
stack<pair<int, int> > shuf;
for(int i = 1; i <= n; i++){
before[i] = i;
}

int l, r;
for(int i = 1; i < x; i++){
cin >> l >> r;
swap(before[l],before[r]);
}

char tmpa,tmpb;
cin >> tmpa >> tmpb;

for(int i = x+1; i <= k; i++){
cin >> l >> r;
shuf.push(make_pair(l,r));
}

for(int i = 1; i <= n; i++){
cin >> after[i];
}

pair<int,int> box;
while(!shuf.empty()){
box = shuf.top(); shuf.pop();
swap(after[box.first], after[box.second]);
}

int A[2];
int pos = 0;
for(int i = 1; i <= n; i++){
if(after[i] != before[i]) A[pos++] = i;
}

cout <<A[0]<<" "<<A[1]<<endl;
return 0;
}
0