結果

問題 No.482 あなたの名は
ユーザー Yamyuki
提出日時 2017-02-11 01:07:19
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 354 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 20,864 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-29 11:43:56
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 17 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |                 ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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++;
			}
		}
	}
	min=(w-p-1)+p/2;
	if(min<=k && min%2==k%2) printf("YES\n");
	else printf("NO\n");
	return 0;
}
0