結果
| 問題 | No.101 ぐるぐる!あみだくじ! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-11 23:35:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 480 bytes |
| 記録 | |
| コンパイル時間 | 413 ms |
| コンパイル使用メモリ | 44,032 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-06-11 20:40:59 |
| 合計ジャッジ時間 | 16,033 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 33 TLE * 1 -- * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d%d",&N,&K);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d%d",&a,&b),a--,b--;
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
using namespace std;
int main(){
int N,K;
scanf("%d%d",&N,&K);
vector<int>shuf(N);
iota(shuf.begin(),shuf.end(),0);
vector<int>orig=shuf;
for(int i=0;i<K;i++){
int a,b;
scanf("%d%d",&a,&b),a--,b--;
swap(shuf[a],shuf[b]);
}
vector<int>v=shuf;
int x=1;
for(;v!=orig;x++){
vector<int>nxt(N);
for(int i=0;i<N;i++)nxt[i]=v[shuf[i]];
v=nxt;
}
printf("%d\n",x);
}