結果

問題 No.482 あなたの名は
ユーザー newlife171128
提出日時 2018-01-06 23:54:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 980 ms
コンパイル使用メモリ 73,900 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 09:19:23
合計ジャッジ時間 2,904 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <cctype>
#include <stdio.h>

using namespace std;

int a[200010];

int main() {

	int n = 0;
	long long k=0;
	cin >> n >> k;

	int tmp = 0;
	int ct = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> tmp;
		a[i] = tmp;
	}
	int t =0;
	for(int i=1;i<=n;i++)while(a[i]!=i){
		t=a[i];
		a[i]=a[t];
		a[t]=t;
		ct++;
	}

		if (ct  % 2 == k % 2  && k>=ct) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}

	return 0;
}
0