結果

問題 No.100 直列あみだくじ
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-05-26 17:27:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,571 bytes
コンパイル時間 1,467 ms
コンパイル使用メモリ 168,052 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 00:13:59
合計ジャッジ時間 2,766 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 WA -
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 WA -
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 2 ms
4,348 KB
testcase_47 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<int NV> struct UF {
    int par[NV], cnt[NV];
    UF() { rep(i, 0, NV) par[i] = i, cnt[i] = 1; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) { // xをyにくっつける
        x = operator[](x); y = operator[](y);
        if (x != y) par[x] = y, cnt[y] += cnt[x];
    }
};
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/



int N;
UF<101> uf;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 1, N + 1) {
        int x; cin >> x;
        uf(i, x);
    }

    int cnt = 0;
    rep(i, 1, N + 1) if (i == uf[i]) {
        if (uf.cnt[i] % 2 == 0) cnt++;
    }

    if(cnt % 2 == 0) printf("Yes\n");
    else printf("No\n");
}
0