結果

問題 No.482 あなたの名は
ユーザー yomo3
提出日時 2020-04-05 20:57:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 169,020 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-04 03:12:23
合計ジャッジ時間 3,329 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    ll N, K; cin >> N >> K;
    vector<int> D(N); cin >> D;

    int c = 0;
    rep(i, N) {
        if (D[i] != i+1) {
            swap(D[i], D[D[i]-1]);
            c++;
        }
    }

    bool ok = (c <= K && (c&1) == (K&1));
    cout << (ok ? "YES" : "NO") << endl;
}
0