結果

問題 No.100 直列あみだくじ
ユーザー koba-e964
提出日時 2015-06-18 14:15:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 443 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 55,352 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 03:38:14
合計ジャッジ時間 1,782 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;


int a[51];
int main(void){
  int n;
  cin >> n;
  int c = 0;
  REP(i, 0, n) {
    cin >> a[i];
    --a[i];
  }
  REP(i, 0, n) {
    int v = a[i];
    int c = 1;
    while (v != i) {
      v = a[v];
      c++;
    }
    if (c % 2 == 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
0