結果

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

テストケース

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

ソースコード

diff #

#include<stdio.h>

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