結果

問題 No.482 あなたの名は
ユーザー suibaka_kusuibaka_ku
提出日時 2017-03-19 15:51:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 93,832 KB
実行使用メモリ 13,344 KB
最終ジャッジ日時 2023-09-18 07:29:06
合計ジャッジ時間 4,463 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 159 ms
13,048 KB
testcase_16 AC 154 ms
12,992 KB
testcase_17 AC 154 ms
13,196 KB
testcase_18 AC 156 ms
13,024 KB
testcase_19 AC 151 ms
13,112 KB
testcase_20 AC 150 ms
13,052 KB
testcase_21 AC 151 ms
13,008 KB
testcase_22 AC 156 ms
12,980 KB
testcase_23 AC 163 ms
13,128 KB
testcase_24 AC 160 ms
13,024 KB
testcase_25 AC 156 ms
13,140 KB
testcase_26 AC 159 ms
13,012 KB
testcase_27 AC 158 ms
13,048 KB
testcase_28 AC 159 ms
13,344 KB
testcase_29 AC 163 ms
13,192 KB
testcase_30 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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) {
            m[D[i]] = m[i];
            D[m[i]] = D[i];
            D[i] = i;
            m[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