結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-11 01:02:29 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 359 bytes |
| コンパイル時間 | 520 ms |
| コンパイル使用メモリ | 20,736 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-29 11:42:56 |
| 合計ジャッジ時間 | 2,217 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 13 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%ld %ld",&n,&k);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:9:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%ld",&b[i]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
long b[200000];
int main(int argc, char const *argv[]) {
long n,k,i,w=0,p=0,min;
scanf("%ld %ld",&n,&k);
for(i=0;i<n;i++){
scanf("%ld",&b[i]);
}
for(i=0;i<n;i++){
if(i+1!=b[i]){
w++;
if(i+1==b[b[i]-1]){
p++;
}
}
}
p/=2;
min=(w-2*p)+p;
if(min<=k && min%2==k%2) printf("YES\n");
else printf("NO\n");
return 0;
}