結果

問題 No.1421 国勢調査 (Hard)
ユーザー tailstails
提出日時 2021-03-10 10:59:32
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,162 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 33,664 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 07:05:04
合計ジャッジ時間 2,670 ms
ジャッジサーバーID
(参考情報)
judge4 / 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 0 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 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 0 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 5 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 AC 5 ms
5,376 KB
testcase_28 AC 4 ms
5,376 KB
testcase_29 AC 5 ms
5,376 KB
testcase_30 AC 4 ms
5,376 KB
testcase_31 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:16:1: warning: return type defaults to 'int' [-Wimplicit-int]
   16 | main(){
      | ^~~~
main.c: In function 'main':
main.c:53:33: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   53 |                                 write(1,"-1\n",3);
      |                                 ^~~~~
main.c:54:33: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   54 |                                 _exit(0);
      |                                 ^~~~~
      |                                 _Exit

ソースコード

diff #

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

char*mmap();
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

char wbuf[1<<28];
#define WTHI(v) {long _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;}
#define WTLO(v) {long _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;}
#define WT(v) if(v>=100000000){WTHI(v/100000000);WTLO(v);}else{WTHI(v);}

long b[10000];
int y[10000];
int r[50];

main(){
	char*rp=mmap(0l,1l<<28,1,2,0,0ll);
	RD(n);
	RD(m);
	for(int j=0;j<m;++j){
		RD(aj);
		long bj=0;
		for(int k=0;k<aj;++k){
			RD(t);
			bj|=1l<<t-1;
		}
		b[j]=bj;
		RD(yj);
		y[j]=yj;
	}
	for(int i=n;i--;){
		int k=-1;
		for(int j=0;j<m;++j){
			if(b[j]>>i==1){
				k=j;
				break;
			}
		}
		if(k>=0){
			for(int j=0;j<m;++j){
				if(j!=k){
					if(b[j]&1l<<i){
						b[j]^=b[k];
						y[j]^=y[k];
					}
				}
			}
		}
	}
	for(int j=0;j<m;++j){
		if(b[j]==0){
			if(y[j]!=0){
				write(1,"-1\n",3);
				_exit(0);
			}
		}else{
			r[63-__builtin_clzl(b[j])]=y[j];
		}
	}
	char*wp=wbuf;
	for(int i=0;i<n;++i){
		int z=r[i];
		WT(z);
		*wp++=10;
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0