結果

問題 No.482 あなたの名は
ユーザー Yut176
提出日時 2017-02-10 23:04:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 647 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 74,444 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-28 09:20:56
合計ジャッジ時間 11,279 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){

  long long int n, k;
  cin >> n >> k;

  vector<long long int> d(n);
  for(int i=0; i<n; i++) cin >> d[i];

  int tmp = 0;
  for(int i=0; i<n; i++){
    if( d[i] != i+1 ){
      swap( d[i], d[ d[i]-1 ] );
      tmp++;
    }
  }

  for(int i=0; i<n; i++) cerr << d[i] << " ";
  cerr << endl;
  cerr << tmp << endl;

  if( (k-tmp)%2 == 0 && k-tmp >= 0 ) cout << "YES" << endl;
  else cout << "NO" << endl;


  return 0;
}
0