結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,796 KB
testcase_01 AC 280 ms
25,220 KB
testcase_02 AC 22 ms
24,836 KB
testcase_03 AC 135 ms
25,220 KB
testcase_04 AC 271 ms
25,220 KB
testcase_05 AC 22 ms
24,836 KB
testcase_06 AC 21 ms
24,964 KB
testcase_07 AC 22 ms
25,220 KB
testcase_08 AC 22 ms
24,580 KB
testcase_09 AC 21 ms
24,964 KB
testcase_10 AC 22 ms
24,580 KB
testcase_11 AC 22 ms
25,220 KB
testcase_12 AC 22 ms
25,220 KB
testcase_13 AC 23 ms
24,836 KB
testcase_14 AC 24 ms
25,220 KB
testcase_15 AC 87 ms
24,836 KB
testcase_16 AC 33 ms
24,964 KB
testcase_17 AC 52 ms
24,836 KB
testcase_18 AC 55 ms
24,580 KB
testcase_19 AC 105 ms
25,220 KB
testcase_20 AC 175 ms
24,580 KB
testcase_21 AC 187 ms
24,580 KB
testcase_22 AC 267 ms
24,836 KB
testcase_23 AC 272 ms
25,220 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,"?    %4d ",n-1);
      |         ^~~~~~~
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 b

ソースコード

diff #

char buf[5*1002];

main(){
	int n;
	scanf("%d",&n);
	sprintf(buf,"?    %4d ",n-1);
	for(int i=1;i<=n;++i){
		sprintf(buf+5*(i+1),"%4d ",i);
	}

	for(int i=1;i<=n;++i){
		char saved[5];
		memcpy(saved,buf+5*(i+1),5);
		memset(buf+5*(i+1),32,5);
		write(1,buf,5*(n+2));
		memcpy(buf+5*(i+1),saved,5);
	}

	buf[0]='!';
	int m=n;
	for(int i=1;i<=n;++i){
		getchar();
		if(getchar()=='1'){
			--m;
			memset(buf+5*(i+1),32,5);
		}
	}

	sprintf(buf+5,"%4d",m);
	buf[9]=32;
	write(1,buf,5*(n+2));
}
0