結果

問題 No.100 直列あみだくじ
ユーザー koyumeishi
提出日時 2014-12-12 00:41:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 695 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 76,336 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 20:54:42
合計ジャッジ時間 1,958 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <ctime>

using namespace std;


int main(){
	srand((unsigned)time(NULL));
	
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
		a[i]--;
	}

	int k=0;

	vector<int> s(n);
	vector<bool> used(n, false);
	for(int i=0; i<n; i++){
		if(used[i]) continue;
		used[i] = true;
		
		int pos = a[i];
		int cnt = 1;
		while(!used[pos]){
			used[pos] = true;
			pos = a[pos];
			cnt++;
		}
		if(cnt%2==0) k++;
	}

	cout << (k%2==0?"Yes":"No") << endl;
	return 0;
}
0