結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
Bantako
|
| 提出日時 | 2017-07-25 14:36:18 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 453 bytes |
| 記録 | |
| コンパイル時間 | 1,063 ms |
| コンパイル使用メモリ | 174,348 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-25 21:18:12 |
| 合計ジャッジ時間 | 2,230 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 13 |
コンパイルメッセージ
main.cpp:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | main(){
| ^~~~
ソースコード
#include<bits/stdc++.h>
main(){
int N,K;
int D[200000];
scanf("%d%d",&N,&K);
for(int i = 0;i < N;i++){
scanf("%d",&D[i]);
}
int count = 0,scnt = 0;
for(int i = 0;i < N;i++){
if(D[i]==i+1)continue;
count++;
if(D[D[i]-1]==i+1)scnt++;
}
count -= scnt/2;
if(count > K){
printf("NO\n");
return 0;
}
printf("%s\n",(K-count)%2?N>=3&&K-count>=3?"YES":"NO":"YES");
}
Bantako