結果

問題 No.482 あなたの名は
ユーザー suibaka_kusuibaka_ku
提出日時 2017-03-19 15:37:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 93,428 KB
実行使用メモリ 13,580 KB
最終ジャッジ日時 2023-09-18 07:28:32
合計ジャッジ時間 4,221 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,500 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 137 ms
13,032 KB
testcase_16 AC 137 ms
13,036 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 137 ms
13,024 KB
testcase_20 WA -
testcase_21 AC 144 ms
13,020 KB
testcase_22 AC 147 ms
13,156 KB
testcase_23 AC 135 ms
12,936 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 138 ms
12,944 KB
testcase_28 AC 135 ms
12,932 KB
testcase_29 AC 135 ms
13,016 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <codecvt>
#include <locale>
using namespace std;
using ll = long long;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> D(N);
    map<int, int> m;
    for(int i=0; i<N; ++i) {
        cin >> D[i];
        D[i]--;
        m[D[i]] = i;
    }
    for(int i=0; i<N && K >= 0; ++i) {
        if(D[i] != i) {
            D[m[i]] = D[i];
            D[i] = i;
            m[D[i]] = i;
            K--;
        }
    }
    bool ok = true;
    for(int i=0; i<N; ++i) {
        ok &= D[i] == i;
    }
    if(!ok || K != 0 && K % 2 == 1) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}
0