結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
25,964 KB
testcase_01 AC 288 ms
25,732 KB
testcase_02 AC 23 ms
25,988 KB
testcase_03 AC 142 ms
25,604 KB
testcase_04 AC 281 ms
25,348 KB
testcase_05 AC 26 ms
25,604 KB
testcase_06 AC 23 ms
25,988 KB
testcase_07 AC 24 ms
25,604 KB
testcase_08 AC 23 ms
25,604 KB
testcase_09 AC 23 ms
25,604 KB
testcase_10 AC 26 ms
25,732 KB
testcase_11 AC 28 ms
25,988 KB
testcase_12 AC 26 ms
25,604 KB
testcase_13 AC 30 ms
25,604 KB
testcase_14 AC 30 ms
25,732 KB
testcase_15 AC 93 ms
25,604 KB
testcase_16 AC 38 ms
25,476 KB
testcase_17 AC 58 ms
25,348 KB
testcase_18 AC 59 ms
25,604 KB
testcase_19 AC 110 ms
25,732 KB
testcase_20 AC 184 ms
25,348 KB
testcase_21 AC 203 ms
25,860 KB
testcase_22 AC 281 ms
25,732 KB
testcase_23 AC 284 ms
25,988 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:10:13: warning: implicit declaration of function 'fork' [-Wimplicit-function-declaration]
   10 |         if(!fork()){
      |             ^~~~
main.c:13:25: 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:25: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch]
   13 |                         memcpy(saved,buf+5*(i+1),5);
      |                         ^~~~~~
main.c:13:25: note: include '<string.h>' or provide a declaration of 'memcpy'
main.c:14:25: warning: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
   14 |                         memse

ソースコード

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);
	}
	if(!fork()){
		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);
		}
	}else{
		buf[0]='!';
		int m=n;
		for(int i=1;i<=n;++i){
			int r;
			scanf("%d",&r);
			if(r){
				--m;
				memset(buf+5*(i+1),32,5);
			}
		}
		{
			sprintf(buf+5,"%4d",m);
			buf[9]=32;
			write(1,buf,5*(n+2));
		}
	}
}
0