結果

問題 No.482 あなたの名は
ユーザー hotpepsihotpepsi
提出日時 2017-06-11 20:57:50
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 462 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 58,236 KB
実行使用メモリ 5,196 KB
最終ジャッジ日時 2023-10-24 21:22:54
合計ジャッジ時間 3,233 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,196 KB
testcase_01 AC 2 ms
5,196 KB
testcase_02 AC 3 ms
5,196 KB
testcase_03 AC 2 ms
5,196 KB
testcase_04 AC 2 ms
5,196 KB
testcase_05 AC 3 ms
5,196 KB
testcase_06 AC 2 ms
5,196 KB
testcase_07 AC 2 ms
5,196 KB
testcase_08 AC 2 ms
5,196 KB
testcase_09 AC 3 ms
5,196 KB
testcase_10 AC 2 ms
5,196 KB
testcase_11 AC 2 ms
5,196 KB
testcase_12 AC 2 ms
5,196 KB
testcase_13 AC 3 ms
5,196 KB
testcase_14 AC 3 ms
5,196 KB
testcase_15 AC 62 ms
5,196 KB
testcase_16 AC 62 ms
5,196 KB
testcase_17 AC 62 ms
5,196 KB
testcase_18 AC 62 ms
5,196 KB
testcase_19 AC 64 ms
5,196 KB
testcase_20 AC 62 ms
5,196 KB
testcase_21 AC 62 ms
5,196 KB
testcase_22 AC 61 ms
5,196 KB
testcase_23 AC 61 ms
5,196 KB
testcase_24 AC 61 ms
5,196 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 3 ms
5,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, k, c = 0;
	cin >> n >> k;
	int d[200001];
	int r[200001];
	for (int i = 1; i <= n; ++i) {
		cin >> d[i];
		r[d[i]] = i;
	}
	for (int i = 1; i <= n; ++i) {
		if (d[i] != i) {
			++c;
			int pos = r[i];
			swap(d[i], d[pos]);
			r[i] = i;
			r[d[pos]] = pos;
		}
	}
	bool ans = c <= k && ((k - c) % 2) == 0;
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}
0