結果

問題 No.1017 Reiwa Sequence
ユーザー tailstails
提出日時 2020-11-01 03:54:32
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 32,888 KB
実行使用メモリ 9,628 KB
最終ジャッジ日時 2023-09-29 11:06:23
合計ジャッジ時間 11,432 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 5 ms
5,372 KB
testcase_13 AC 4 ms
4,592 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 6 ms
5,736 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 14 ms
8,904 KB
testcase_20 AC 13 ms
8,884 KB
testcase_21 AC 14 ms
9,188 KB
testcase_22 AC 14 ms
9,116 KB
testcase_23 AC 13 ms
9,036 KB
testcase_24 AC 14 ms
9,076 KB
testcase_25 AC 14 ms
8,840 KB
testcase_26 AC 12 ms
8,684 KB
testcase_27 AC 9 ms
7,944 KB
testcase_28 AC 10 ms
8,004 KB
testcase_29 AC 9 ms
7,520 KB
testcase_30 AC 6 ms
6,556 KB
testcase_31 AC 7 ms
6,480 KB
testcase_32 AC 4 ms
4,696 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 0 ms
4,376 KB
testcase_35 AC 11 ms
8,484 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 10 ms
7,772 KB
testcase_39 AC 5 ms
6,152 KB
testcase_40 AC 4 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 3 ms
4,384 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 0 ms
4,376 KB
testcase_52 AC 4 ms
4,376 KB
testcase_53 AC 14 ms
9,628 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘yes’ 内:
main.c:10:13: 警告: 関数 ‘sprintf’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   10 |         wp+=sprintf(wp,"Yes\n");
      |             ^~~~~~~
main.c:1:1: 備考: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
  +++ |+#include <stdio.h>
    1 | #pragma GCC optimize("Ofast")
main.c:10:13: 警告: 組み込み関数 ‘sprintf’ の互換性がない暗黙的な宣言です [-Wbuiltin-declaration-mismatch]
   10 |         wp+=sprintf(wp,"Yes\n");
      |             ^~~~~~~
main.c:10:13: 備考: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
main.c:21:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   21 |         write(1,&v,wp-(char*)&v);
      |         ^~~~~
main.c:22:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   22 |         _exit(0);
      |         ^~~~~
      |         _Exit
main.c: トップレベル:
main.c:34:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   34 | main(){
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:35:9: 警告: 関数 ‘scanf’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   35 |         scanf("%d",&n);
      |         ^~~~~
main.c:35:9: 備考: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:35:9: 警告: 組み込み関数 ‘scanf’ の互換性がない暗黙的な宣言です [-Wbuiltin-declaration-mismatch]
main.c:35:9: 備考: include ‘<stdio.h>’ or provide a declaration of ‘scanf’

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define MAX (150000*22+1)
int n,m,a[22];
int v[MAX];

void yes(int p1,int p2){
	char*wp=(char*)&v;
	wp+=sprintf(wp,"Yes\n");
	for(int i=0;i<m;++i){
		int b=a[i]*((p1&1)-(p2&1));
		wp+=sprintf(wp,"%d ",b);
		p1>>=1;
		p2>>=1;
	}
	n-=m;
	while((long)wp&7) *wp++=32;
	while(n>=4) *(long*)wp=0x2030203020302030l, wp+=8, n-=4;
	while(n) *(short*)wp=0x2030, wp+=2, --n;
	write(1,&v,wp-(char*)&v);
	_exit(0);
}

void f(int i,int p,int s){
	if(i==m) return;
	f(i+1,p,s);
	int s1=s+a[i];
	int p1=p|1<<i;
	if(v[s1]) yes(v[s1],p1);
	f(i+1,v[s1]=p1,s1);
}

main(){
	scanf("%d",&n);
	m=n<22?n:22;
	for(int i=0;i<m;++i) scanf("%d",&a[i]);
	f(0,0,0);
	write(1,"No\n",3);
	_exit(0);
}
0