結果

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

ソースコード

diff #

#include <stdio.h>

int main(){
    int n,i,cnt=0,temp;
    double k;
    scanf("%d",&n);
    scanf("%lf",&k);
    int d[n+1];
    for(i=1;i<=n;i++){
        scanf("%d",&d[i]);
    }
    while(i){
        int CNT=0;
        for(i=1;i<=n;i++){
            if(d[i]!=i){
                temp=d[d[i]];
                d[d[i]]=d[i];
                d[i]=temp;
                cnt++;
                CNT++;
            }
        }
        if(CNT==0)break;
    }
    if(cnt==k||cnt==0)printf("YES\n");
    else printf("NO\n");
    return 0;
}
0