結果

問題 No.241 出席番号(1)
ユーザー twtw50763695twtw50763695
提出日時 2018-12-24 15:33:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 22,528 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 03:02:43
合計ジャッジ時間 4,366 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 0 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 0 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 0 ms
4,348 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 scanf("%d",&a[i]);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(){
	
	int i;
	int n;
	int j;
	int t;
	int e;
	int a[50];
	int num[50];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<n;i++){
		num[i]=i;
	}
	
	for(i=0;i<n;i++){
		if(num[i]==a[i]){
			for(j=0;j<n-1;j++){
				if(num[i]!=a[j]){
					t=num[i];
					num[i]=num[j];
					num[j]=t;
					break;
				}
				if(j==n-2){
					e=-1;
				}
			}
		}
	}
	
	if(e==-1){
		printf("%d\n",e);
	}else{
		for(i=0;i<n;i++){
			printf("%d\n",num[i]);
		}
		
		
	}
	
}
0