結果
問題 | No.100 直列あみだくじ |
ユーザー |
|
提出日時 | 2015-01-17 23:56:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,033 bytes |
コンパイル時間 | 735 ms |
コンパイル使用メモリ | 93,044 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 01:36:15 |
合計ジャッジ時間 | 1,978 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for(int i=0; i<n; ++i){ cin >> a[i]; -- a[i]; } vector<bool> check(n, false); vector<int> cnt(n+1, 0); for(int i=0; i<n; ++i){ if(check[i]) continue; int k = i; int len = 0; while(!check[k]){ check[k] = true; k = a[k]; ++ len; } ++ cnt[len]; } bool ok = true; for(int i=2; i<=n; i+=2){ if(cnt[i] % 2 != 0) ok = false; } if(ok) cout << "Yes" << endl; else cout << "No" << endl; return 0; }