結果

問題 No.482 あなたの名は
ユーザー ふっぴーふっぴー
提出日時 2017-05-01 22:06:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 166,144 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 02:27:33
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int n,i,j;
	ll k;
	cin>>n>>k;
	vi d(n+1);
	loop(i,1,n+1){
		cin>>d[i];
	}
	int start,next;
	ll sum=0;
	loop(i,1,n+1){
		if(d[i]==i){
			d[i]=0;
		}else if(d[i]!=0){
			start=i;
			j=i;
			next=d[j];
			d[j]=0;
			while(next!=start){
				sum++;
				j=next;
				next=d[j];
				d[j]=0;
			}
		}
	}
	if(k-sum>=0 && (k-sum)%2==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}
0