結果

問題 No.482 あなたの名は
ユーザー tonyu0tonyu0
提出日時 2019-10-25 19:17:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 64,400 KB
実行使用メモリ 5,364 KB
最終ジャッジ日時 2023-09-28 21:23:34
合計ジャッジ時間 2,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 24 ms
5,104 KB
testcase_16 AC 24 ms
5,144 KB
testcase_17 AC 23 ms
5,120 KB
testcase_18 AC 23 ms
5,180 KB
testcase_19 AC 23 ms
5,364 KB
testcase_20 AC 23 ms
5,180 KB
testcase_21 AC 24 ms
5,140 KB
testcase_22 AC 23 ms
5,132 KB
testcase_23 AC 23 ms
5,140 KB
testcase_24 AC 24 ms
5,264 KB
testcase_25 AC 23 ms
5,104 KB
testcase_26 AC 23 ms
5,208 KB
testcase_27 AC 23 ms
5,104 KB
testcase_28 AC 24 ms
5,116 KB
testcase_29 AC 21 ms
5,124 KB
testcase_30 AC 1 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];

  ll 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 << endl;

  return 0;
}
0