結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2016-01-06 16:10:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,147 bytes |
| コンパイル時間 | 392 ms |
| コンパイル使用メモリ | 58,328 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-09-19 12:16:26 |
| 合計ジャッジ時間 | 4,056 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 1 -- * 5 |
ソースコード
//0-indexedな愚直解(入力値の変更なし)
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n, k, x;
int a[100000], b[100000];
int c[100000];
bool isOk(){
int i;
static int d[100000]; //シミュレーション用、d[i]=位置iにあるコップ
for( i = 0; i < n; i++ ){
d[i] = i + 1;
}
for( i = 0; i < k; i++ ){
swap(d[a[i] - 1], d[b[i] - 1]);
}
for( i = 0; i < n; i++ ){
//合っていなければfalseを返す
if( c[i] != d[i] ){
return false;
}
}
//正解.やったね!
return true;
}
int main()
{
int i, j;
cin >> n >> k >> x;
for( i = 0; i < k; i++ ){
if( i == x - 1 ){
string yuki, coder;
cin >> yuki >> coder;
}
else{
cin >> a[i] >> b[i];
}
}
for( i = 0; i < n; i++ ){
cin >> c[i];
}
for( i = 0; i < n; i++ ){
for( j = i + 1; j < n; j++ ){
//?を埋めてみる
a[x - 1] = i + 1;
b[x - 1] = j + 1;
//シミュレーションする→正解かどうか判定する
if( isOk() ){
cout << a[x - 1] << " " << b[x - 1] << endl;
return 0;
}
}
}
cout << "答えがない!訴訟!" << endl;
return 0;
}
startcpp