結果

問題 No.1017 Reiwa Sequence
ユーザー tailstails
提出日時 2020-11-01 22:16:59
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,135 bytes
コンパイル時間 1,337 ms
コンパイル使用メモリ 136,784 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-22 05:53:25
合計ジャッジ時間 34,941 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 4 ms
6,528 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 7 ms
7,552 KB
testcase_13 AC 4 ms
6,784 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 6 ms
6,272 KB
testcase_20 AC 5 ms
7,680 KB
testcase_21 AC 6 ms
7,680 KB
testcase_22 AC 6 ms
7,680 KB
testcase_23 AC 6 ms
7,168 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 5 ms
6,400 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 6 ms
7,808 KB
testcase_28 AC 5 ms
7,424 KB
testcase_29 AC 5 ms
6,144 KB
testcase_30 AC 4 ms
5,376 KB
testcase_31 AC 4 ms
6,528 KB
testcase_32 AC 4 ms
6,400 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 5 ms
7,680 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 5 ms
6,912 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 4 ms
5,632 KB
testcase_40 AC 9 ms
9,984 KB
testcase_41 AC 8 ms
9,216 KB
testcase_42 AC 9 ms
10,624 KB
testcase_43 AC 8 ms
10,496 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 7 ms
7,808 KB
testcase_46 AC 5 ms
6,912 KB
testcase_47 AC 3 ms
5,376 KB
testcase_48 AC 6 ms
6,656 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 6 ms
8,064 KB
testcase_53 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'yes':
main.c:12:13: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration]
   12 |         wp+=sprintf(wp,"Yes\n");
      |             ^~~~~~~
main.c:5:1: note: include '<stdio.h>' or provide a declaration of 'sprintf'
    4 | #include <immintrin.h>
  +++ |+#include <stdio.h>
    5 | 
main.c:12:13: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch]
   12 |         wp+=sprintf(wp,"Yes\n");
      |             ^~~~~~~
main.c:12:13: note: include '<stdio.h>' or provide a declaration of 'sprintf'
main.c:23:48: warning: passing argument 1 of '_mm256_stream_si256' from incompatible pointer type [-Wincompatible-pointer-types]
   23 |                 while(n>0) _mm256_stream_si256(wp,r), wp+=32, n-=16;
      |                                                ^~
      |                                                |
      |                                                char *
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/lib/gcc/12/gcc/x86_64-pc-linux-gnu/12/include/immintrin.h:43,
                 from main.c:4:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/lib/gcc/12/gcc/x86_64-pc-linux-gnu/12/include/avxintrin.h:1015:31: note: expected '__m256i *' but argument is of type 'char *'
 1015 | _mm256_stream_si256 (__m256i *__A, __m256i __B)
      |                      ~~~~~~~~~^~~
main.c:26:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   26 |         write(1,&v,wp-(char*)&v);
      |         ^~~~~
main.c:27:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   27 |         _exit(0);
      |         ^~~~~
      |         _Exit
main.c: At top level:
main.c:55:1: warning: return type defaults to 'int' [-Wimplicit-int]
   55 | main(){
      | ^~~~
main.c: In function 'main':
main.c:56:9: warning: implicit declaration of function 'scanf' [-Wimplicit

ソースコード

diff #

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

#include <immintrin.h>

#define OFFS (150000*11+1)
int n,m,m1,a[22];
int v[OFFS*2];

void yes(long p){
	char*wp=(char*)&v;
	wp+=sprintf(wp,"Yes\n");
	int*ap=a;
	while(p){
		int b=*ap++*((p&1?1:p&2?-1:0));
		wp+=sprintf(wp,"%d ",b);
		p>>=2;
		--n;
	}
	while((long)wp&31) *wp++=32;
	{
		__m256i r=_mm256_set1_epi16(0x2030);
		while(n>0) _mm256_stream_si256(wp,r), wp+=32, n-=16;
	}
	wp+=n*2;
	write(1,&v,wp-(char*)&v);
	_exit(0);
}

void f1(int i,int p,int s){
	if(i==m1) return;
	f1(i+1,p,s);
	int s1=s+a[i];
	int p1=p|1<<i*2;
	if(s1==OFFS) yes(p1);
	f1(i+1,v[s1]=p1,s1);
	int s2=s-a[i];
	int p2=p|2<<i*2;
	f1(i+1,v[s2]=p2,s2);
}

void f2(int i,int p,int s){
	if(i==m) return;
	f2(i+1,p,s);
	int s1=s-a[i];
	int p1=p|1<<(i-m1)*2;
	if(v[s1]) yes((v[s1]<0?0:v[s1])|(long)p1<<(m1<<1));
	f2(i+1,p1,s1);
	int s2=s+a[i];
	int p2=p|2<<(i-m1)*2;
	if(v[s2]) yes((v[s2]<0?0:v[s2])|(long)p2<<(m1<<1));
	f2(i+1,p2,s2);
}

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