結果

問題 No.101 ぐるぐる!あみだくじ!
コンテスト
ユーザー ciel
提出日時 2014-12-11 23:35:41
言語 C++11
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 480 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 308 ms
コンパイル使用メモリ 65,580 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-25 18:09:09
合計ジャッジ時間 13,801 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 33 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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);
}
0