結果

問題 No.482 あなたの名は
ユーザー tonyu0tonyu0
提出日時 2019-10-25 19:08:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 544 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 65,108 KB
実行使用メモリ 5,388 KB
最終ジャッジ日時 2023-09-28 21:07:19
合計ジャッジ時間 3,317 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 24 ms
5,388 KB
testcase_16 AC 23 ms
5,164 KB
testcase_17 AC 23 ms
5,136 KB
testcase_18 AC 23 ms
5,160 KB
testcase_19 AC 23 ms
5,284 KB
testcase_20 AC 23 ms
5,128 KB
testcase_21 AC 23 ms
5,200 KB
testcase_22 AC 23 ms
5,188 KB
testcase_23 AC 24 ms
5,120 KB
testcase_24 AC 23 ms
5,132 KB
testcase_25 AC 23 ms
5,132 KB
testcase_26 AC 23 ms
5,264 KB
testcase_27 AC 23 ms
5,148 KB
testcase_28 AC 23 ms
5,144 KB
testcase_29 AC 21 ms
5,168 KB
testcase_30 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
using ll = long long;

ll N, K, D[200020];
bool used[200020];

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false); 
  cin >> N >> K;
  for(int i = 1; i <= N; ++i) cin >> D[i];

  int ans = 0;
  for(int i = 1; i <= N; ++i) {
    if(!used[i] && i != D[i]) {
      used[i] = true;
      int pos = D[i];
      while(pos != i) {
        used[pos] = true;
        pos = D[pos];
        ++ans;
      }
    }
  }
  if(ans % 2 == K % 2) cout << "YES";
  else cout << "NO";
  cout << '\n';
  return 0;
}
0