結果

問題 No.482 あなたの名は
ユーザー nksk38
提出日時 2017-06-29 22:56:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 73,392 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 16:54:16
合計ジャッジ時間 2,449 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

#define mod 1000000007;

using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pr;

ll N, K;
ll D[200010],ind[200010];

int main()
{
	cin >> N >> K;
	for (ll i = 1; i <= N; i++) {
		cin >> D[i];
		ind[i] = D[i];
	}

	ll cnt = 0;
	for (ll i = 1; i <= N; i++) {
		if (D[i] != i) {
			swap(D[ind[i]],D[i]);
			cnt++;
		}
	}

	if (K < cnt || (K - cnt) % 2 != 0)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}
0