結果

問題 No.934 Explosive energy drink
ユーザー tailstails
提出日時 2020-12-16 12:32:12
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 28,544 KB
実行使用メモリ 25,220 KB
平均クエリ数 1.00
最終ジャッジ日時 2024-07-17 10:13:18
合計ジャッジ時間 5,839 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
25,196 KB
testcase_01 AC 210 ms
25,220 KB
testcase_02 AC 22 ms
25,208 KB
testcase_03 AC 110 ms
25,076 KB
testcase_04 AC 279 ms
25,064 KB
testcase_05 AC 22 ms
24,836 KB
testcase_06 AC 22 ms
25,220 KB
testcase_07 AC 21 ms
24,964 KB
testcase_08 AC 21 ms
24,952 KB
testcase_09 AC 23 ms
25,220 KB
testcase_10 AC 23 ms
24,580 KB
testcase_11 AC 30 ms
25,208 KB
testcase_12 AC 23 ms
24,836 KB
testcase_13 AC 26 ms
24,836 KB
testcase_14 AC 27 ms
25,220 KB
testcase_15 AC 92 ms
25,208 KB
testcase_16 AC 35 ms
24,836 KB
testcase_17 AC 49 ms
25,220 KB
testcase_18 AC 51 ms
24,836 KB
testcase_19 AC 87 ms
24,964 KB
testcase_20 AC 142 ms
24,836 KB
testcase_21 AC 150 ms
24,836 KB
testcase_22 AC 207 ms
25,220 KB
testcase_23 AC 209 ms
24,580 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
    3 | main(){
      | ^~~~
main.c: In function 'main':
main.c:5:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |         scanf("%d",&n);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | char buf[5*1002];
main.c:5:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |         scanf("%d",&n);
      |         ^~~~~
main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:9: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration]
    6 |         sprintf(buf,"?    ");
      |         ^~~~~~~
main.c:6:9: note: include '<stdio.h>' or provide a declaration of 'sprintf'
main.c:6:9: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch]
main.c:6:9: note: include '<stdio.h>' or provide a declaration of 'sprintf'
main.c:13:17: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
   13 |                 memcpy(saved,buf+5*(i+1),5);
      |                 ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy'
  +++ |+#include <string.h>
    1 | char buf[5*1002];
main.c:13:17: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch]
   13 |                 memcpy(saved,buf+5*(i+1),5);
      |                 ^~~~~~
main.c:13:17: note: include '<string.h>' or provide a declaration of 'memcpy'
main.c:14:17: warning: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
   14 |                 memset(buf+5*(i+1),32,5);
      |                 ^~~~~~
main.c:14:17: note: include '<string.h>' or provide a declaration of 'memset'
main.c:14:17: warning: incompatible implicit declaration of built-in 

ソースコード

diff #

char buf[5*1002];

main(){
	int n;
	scanf("%d",&n);
	sprintf(buf,"?    ");
	for(int i=1;i<=n;++i){
		sprintf(buf+5*(i+1),"%4d ",i);
	}
	int m=n;
	for(int i=1;i<=n&&m>2;++i){
		char saved[5];
		memcpy(saved,buf+5*(i+1),5);
		memset(buf+5*(i+1),32,5);
		--m;
		sprintf(buf+5,"%4d",m);
		buf[9]=32;
		write(1,buf,5*(n+2));
		int r;
		scanf("%d",&r);
		if(!r){
			++m;
			memcpy(buf+5*(i+1),saved,5);
		}
	}
	{
		buf[0]='!';
		sprintf(buf+5,"%4d",m);
		buf[9]=32;
		write(1,buf,5*(n+2));
	}
}
0