結果

問題 No.482 あなたの名は
ユーザー oxyshower
提出日時 2020-01-12 16:35:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 168,300 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 14:55:06
合計ジャッジ時間 4,188 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    while(d[i] != i){
      swap(d[i], d[d[i]]);
      ans++;
    }
  }
  if(ans <= k && ans % 2 == k % 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}
0