結果
| 問題 |
No.482 あなたの名は
|
| ユーザー |
splatatsugoma
|
| 提出日時 | 2017-02-11 00:19:43 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 675 bytes |
| コンパイル時間 | 132 ms |
| コンパイル使用メモリ | 24,064 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 03:14:42 |
| 合計ジャッジ時間 | 1,715 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:23:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d",&N);
| ^~~~~~~~~~~~~~
main.c:24:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%lf",&K);
| ^~~~~~~~~~~~~~~
main.c:27:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d",&ary[i]);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <math.h>
double count=0;
void swap(int x[ ], int i, int j)
{
int temp;
temp = x[i];
x[i] = x[j];
x[j] = temp;
}
int main(){
int i=0,N,ary[200000],cp[200000],ans,flag=0;
double K,z;
scanf("%d",&N);
scanf("%lf",&K);
for(i=0;i<N;i++){
scanf("%d",&ary[i]);
}
i=0;
while(i<N){
if(ary[i]!=i+1){
swap(ary,i,ary[i]-1);
count++;
}else i++;
}
z=fmod((double)(K-count),2.0);
if(count<=K){
if(z==0) flag=1;
else if(z==1) flag=0;
}else{
flag =2;
}
if(flag==0) printf("NO\n");
else if(flag==1) printf("YES\n");
else if(flag==2) printf("NO\n");
return 0;
}
splatatsugoma