結果

問題 No.482 あなたの名は
ユーザー hotpepsihotpepsi
提出日時 2017-06-11 21:00:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 58,580 KB
実行使用メモリ 5,244 KB
最終ジャッジ日時 2023-10-24 21:22:22
合計ジャッジ時間 3,170 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	long long 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