結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,932 KB
testcase_01 AC 3 ms
4,920 KB
testcase_02 AC 3 ms
4,988 KB
testcase_03 AC 3 ms
5,000 KB
testcase_04 AC 3 ms
5,008 KB
testcase_05 AC 3 ms
4,948 KB
testcase_06 AC 3 ms
5,008 KB
testcase_07 AC 3 ms
5,132 KB
testcase_08 AC 3 ms
4,920 KB
testcase_09 AC 3 ms
5,144 KB
testcase_10 AC 3 ms
5,156 KB
testcase_11 AC 4 ms
4,976 KB
testcase_12 AC 4 ms
5,192 KB
testcase_13 AC 3 ms
4,992 KB
testcase_14 AC 3 ms
4,924 KB
testcase_15 AC 155 ms
19,076 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 159 ms
19,020 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 154 ms
18,964 KB
testcase_27 AC 154 ms
19,128 KB
testcase_28 AC 159 ms
19,076 KB
testcase_29 AC 195 ms
19,020 KB
testcase_30 AC 3 ms
5,060 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);
    ll n, k;
    cin >> n >> k;
    ll d[n];
    rep(i, n) cin >> d[i];
    map<ll, ll> 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]];
            }
        }
    }
    ll a[200001] = {0};
    for (auto e : mp) {
        a[e.S]++;
    }
    // rep(i, 200001) out(a[i]);
    ll 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