結果

問題 No.482 あなたの名は
ユーザー p_squ1d
提出日時 2017-02-10 23:18:06
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 23,424 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-29 04:29:22
合計ジャッジ時間 2,005 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ^~~~~~~~~~~~~~
main.c:8:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%lf",&k);
      |     ^~~~~~~~~~~~~~~
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d",&d[i]);
      |         ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int main(){
    int n,i,temp;
    double k,cnt=0;
    scanf("%d",&n);
    scanf("%lf",&k);
    int d[n+1];
    for(i=1;i<=n;i++){
        scanf("%d",&d[i]);
    }

     for(i=1;i<=n;i++){
        if(d[i]!=i){
        temp=d[d[i]];
        d[d[i]]=d[i];
        d[i]=temp;
        cnt++;
        }
    }
    if(cnt==k)printf("YES\n");
    else if(cnt==0&&fmod(k,2.0)==0)printf("YES\n");
    else printf("NO\n");
    return 0;
}
0