結果

問題 No.482 あなたの名は
ユーザー tactac
提出日時 2019-08-01 11:32:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,296 bytes
コンパイル時間 1,841 ms
コンパイル使用メモリ 174,912 KB
実行使用メモリ 14,484 KB
最終ジャッジ日時 2023-09-18 17:19:55
合計ジャッジ時間 5,495 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 147 ms
14,392 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 147 ms
14,368 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 134 ms
13,484 KB
testcase_28 AC 133 ms
13,724 KB
testcase_29 WA -
testcase_30 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int d[n];
    rep(i, n) cin >> d[i];
    map<int, int> mp;
    int c = 0;
    rep(i, n) {
        if (mp[i + 1] == 0 && mp[d[i]] == 0) {
            mp[i + 1] = ++c;
            mp[d[i]] = c;
        } else {
            if (mp[i + 1]) {
                mp[d[i]] = mp[i + 1];
            } else {
                mp[i + 1] = mp[d[i]];
            }
        }
    }
    int a[200001] = {0};
    for (auto e : mp) {
        a[e.S]++;
    }
    int ans = 0;
    rep(i, 200001) {
        if (a[i] < 2) continue;
        ans += a[i] - 1;
    }
    if (ans <= k && ans % 2 == k % 2) out("YES");
    else out("NO");
}

0