結果

問題 No.482 あなたの名は
ユーザー Naco
提出日時 2019-10-25 14:53:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 465 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 165,968 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 18:09:38
合計ジャッジ時間 4,268 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    int N; long long K; cin >> N >> K;
    int D[N];
    for(int i=0;i<N;i++) cin >> D[i];
    int ans=0;
    for(int i=0;i<N;i++){
        if(D[i]!=i+1){
            ans++;
            swap(D[i],D[D[i]-1]);
        }
    }
    if(ans>K){
        cout << "NO" << endl;
    }else{
        if((K-ans)%2==0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}
0