結果

問題 No.482 あなたの名は
ユーザー m77_m77_
提出日時 2017-05-07 21:09:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 61,212 KB
実行使用メモリ 5,128 KB
最終ジャッジ日時 2023-10-12 16:13:00
合計ジャッジ時間 2,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,940 KB
testcase_01 AC 3 ms
4,884 KB
testcase_02 AC 2 ms
4,936 KB
testcase_03 AC 3 ms
4,952 KB
testcase_04 AC 2 ms
4,940 KB
testcase_05 AC 3 ms
4,876 KB
testcase_06 AC 3 ms
4,876 KB
testcase_07 AC 3 ms
4,884 KB
testcase_08 AC 2 ms
4,876 KB
testcase_09 AC 3 ms
4,884 KB
testcase_10 AC 3 ms
4,928 KB
testcase_11 AC 3 ms
4,992 KB
testcase_12 AC 3 ms
5,004 KB
testcase_13 AC 3 ms
5,076 KB
testcase_14 AC 3 ms
4,884 KB
testcase_15 AC 21 ms
4,884 KB
testcase_16 AC 21 ms
5,052 KB
testcase_17 AC 21 ms
4,884 KB
testcase_18 AC 21 ms
4,888 KB
testcase_19 AC 21 ms
4,876 KB
testcase_20 AC 22 ms
5,128 KB
testcase_21 AC 21 ms
4,880 KB
testcase_22 AC 22 ms
4,940 KB
testcase_23 AC 21 ms
4,856 KB
testcase_24 AC 21 ms
4,880 KB
testcase_25 AC 22 ms
4,932 KB
testcase_26 AC 22 ms
5,012 KB
testcase_27 AC 21 ms
5,004 KB
testcase_28 AC 21 ms
4,944 KB
testcase_29 AC 19 ms
4,888 KB
testcase_30 AC 3 ms
5,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#define SIZE 30
using std::vector;
using std::cin;
using std::cout;
using std::endl;
using std::sort;

 
 
int main() {
	std::cin.tie(0);std::ios::sync_with_stdio(false);
	int64_t n; int64_t k;
	int d[200001] = {};
	int b[200001] = {};
	cin >> n;
	cin >> k;
	int64_t inp;
	int64_t count=0;
	for(int i=1;i<=n;++i){
		cin>>d[i];
	}
	for(int i=1;i<=n;++i){
		if(b[i]==0){
			b[i]=1;
			int j = i;
			while(d[j]!=i){
				j = d[j];
				count++;
				b[j]=1;
			}
		}
	}
	
	if(count > k || count%2 != k%2){
		cout << "NO";
	}else{
		cout << "YES";
	}
	
	
	return 0;
}
0