結果

問題 No.482 あなたの名は
ユーザー rogi52rogi52
提出日時 2022-09-29 23:54:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 200,856 KB
実行使用メモリ 4,660 KB
最終ジャッジ日時 2023-08-24 05:12:16
合計ジャッジ時間 4,998 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 22 ms
4,540 KB
testcase_16 AC 22 ms
4,532 KB
testcase_17 AC 22 ms
4,536 KB
testcase_18 AC 22 ms
4,652 KB
testcase_19 AC 22 ms
4,580 KB
testcase_20 AC 22 ms
4,528 KB
testcase_21 AC 22 ms
4,488 KB
testcase_22 AC 22 ms
4,484 KB
testcase_23 AC 22 ms
4,536 KB
testcase_24 AC 23 ms
4,620 KB
testcase_25 AC 23 ms
4,464 KB
testcase_26 AC 23 ms
4,636 KB
testcase_27 AC 22 ms
4,660 KB
testcase_28 AC 23 ms
4,540 KB
testcase_29 AC 19 ms
4,608 KB
testcase_30 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N; ll K; cin >> N >> K;
    vector<int> D(N);
    rep(i,N) cin >> D[i], D[i]--;

    ll mi = 0;
    vector<int> used(N, 0);
    rep(i,N) if(!used[i]) {
        int v = i;
        do {
            used[v] = true;
            v = D[v];
            mi++;
        } while(v != i);
        mi--;
    }

    cout << (mi <= K && (K - mi) % 2 == 0 ? "YES" : "NO") << endl;
}
0