結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2016-01-06 16:12:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,147 bytes |
| コンパイル時間 | 588 ms |
| コンパイル使用メモリ | 58,400 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-09-19 12:16:39 |
| 合計ジャッジ時間 | 4,055 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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]], d[b[i]]);
}
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;
x--;
for( i = 0; i < k; i++ ){
if( i == x ){
string yuki, coder;
cin >> yuki >> coder;
}
else{
cin >> a[i] >> b[i];
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] = i;
b[x] = j;
//シミュレーションする→正解かどうか判定する
if( isOk() ){
cout << a[x] + 1 << " " << b[x] + 1 << endl;
return 0;
}
}
}
cout << "答えがない!訴訟!" << endl;
return 0;
}
startcpp