結果
| 問題 |
No.101 ぐるぐる!あみだくじ!
|
| コンテスト | |
| ユーザー |
koyopro
|
| 提出日時 | 2015-10-01 23:44:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 581 bytes |
| コンパイル時間 | 1,653 ms |
| コンパイル使用メモリ | 161,140 KB |
| 実行使用メモリ | 10,144 KB |
| 最終ジャッジ日時 | 2024-07-19 19:01:10 |
| 合計ジャッジ時間 | 19,073 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 27 TLE * 1 -- * 9 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
int N,K;
bool isok(vector<int> a) {
REP(i,a.size()) {
if (a[i] != i) return false;
}
return true;
}
signed main()
{
cin >> N>>K;
vector<int> amida(N);
REP(i,N) amida[i] = i;
vector<int> x(K);
int y;
REP(i,K) {
cin >> x[i] >> y;
}
int cnt = 0;
while(true) {
cnt++;
REP(i,K) {
swap(amida[x[i]-1], amida[x[i]]);
}
if (isok(amida)) break;
}
cout << cnt << endl;
return 0;
}
koyopro