結果

問題 No.482 あなたの名は
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-02-10 23:38:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 163,676 KB
実行使用メモリ 5,288 KB
最終ジャッジ日時 2023-08-28 09:23:32
合計ジャッジ時間 3,295 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 24 ms
5,004 KB
testcase_17 AC 25 ms
5,080 KB
testcase_18 WA -
testcase_19 AC 25 ms
5,020 KB
testcase_20 AC 24 ms
4,928 KB
testcase_21 WA -
testcase_22 AC 25 ms
4,932 KB
testcase_23 AC 25 ms
4,972 KB
testcase_24 WA -
testcase_25 AC 23 ms
4,964 KB
testcase_26 AC 24 ms
4,996 KB
testcase_27 AC 23 ms
4,948 KB
testcase_28 WA -
testcase_29 AC 23 ms
4,976 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




typedef long long ll;
int N; ll K;
int D[201010];
//-----------------------------------------------------------------
int idx[201010];
int main() {
	cin >> N >> K;
	rep(i, 0, N) scanf("%d", &D[i]), D[i]--;

	rep(i, 0, N) idx[D[i]] = i;

	int cnt = 0;
	rep(i, 0, N) {
		if (idx[i] == i) continue;

		int a = i;
		int b = idx[i];
		swap(idx[a], idx[b]);
		cnt++;
	}

	ll d = K - cnt;

	if (0 <= d && d % 2 == 0)
		printf("YES\n");
	else
		printf("NO\n");
}
0