結果

問題 No.482 あなたの名は
ユーザー zaichuzaichu
提出日時 2017-02-16 22:32:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 68,472 KB
実行使用メモリ 4,712 KB
最終ジャッジ日時 2023-08-28 17:49:16
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 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 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 21 ms
4,468 KB
testcase_16 AC 21 ms
4,476 KB
testcase_17 AC 21 ms
4,556 KB
testcase_18 AC 21 ms
4,460 KB
testcase_19 AC 21 ms
4,464 KB
testcase_20 AC 21 ms
4,508 KB
testcase_21 AC 22 ms
4,712 KB
testcase_22 AC 22 ms
4,600 KB
testcase_23 AC 21 ms
4,544 KB
testcase_24 AC 21 ms
4,596 KB
testcase_25 AC 22 ms
4,696 KB
testcase_26 AC 22 ms
4,696 KB
testcase_27 AC 22 ms
4,604 KB
testcase_28 AC 22 ms
4,628 KB
testcase_29 AC 20 ms
4,604 KB
testcase_30 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  long n,k;
  cin >> n >> k;
  vector<long> d(n);
  for(int i = 0; i < n; i++){
    cin >> d[i];
    d[i]--;
  }

  bool flag = true;

  for(int i = 0; i < n; i++){
    if(i == d[i]) continue;
    if(k < 0){
      flag = false;
      break;
    }
    swap(d[d[i]],d[i]);
    k--;
    i--;
  }
  if(flag and k % 2 != 0) flag = false;
  cout << (flag ? "YES" : "NO") << endl;

  return 0;
}
0