結果

問題 No.1913 Periodic Comparison
ユーザー tailstails
提出日時 2022-04-25 12:24:16
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 999 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 30,012 KB
実行使用メモリ 13,860 KB
最終ジャッジ日時 2023-09-09 15:05:12
合計ジャッジ時間 12,090 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,456 KB
testcase_01 AC 3 ms
4,556 KB
testcase_02 AC 4 ms
4,492 KB
testcase_03 AC 4 ms
4,504 KB
testcase_04 AC 3 ms
4,508 KB
testcase_05 AC 3 ms
4,548 KB
testcase_06 AC 3 ms
4,504 KB
testcase_07 AC 3 ms
4,460 KB
testcase_08 AC 11 ms
7,708 KB
testcase_09 AC 24 ms
13,740 KB
testcase_10 AC 10 ms
7,520 KB
testcase_11 AC 23 ms
13,744 KB
testcase_12 AC 11 ms
11,004 KB
testcase_13 AC 9 ms
7,144 KB
testcase_14 AC 20 ms
11,428 KB
testcase_15 AC 24 ms
13,688 KB
testcase_16 AC 21 ms
11,332 KB
testcase_17 AC 10 ms
7,676 KB
testcase_18 AC 10 ms
7,332 KB
testcase_19 AC 24 ms
13,732 KB
testcase_20 AC 16 ms
11,308 KB
testcase_21 AC 22 ms
13,796 KB
testcase_22 AC 10 ms
7,256 KB
testcase_23 AC 6 ms
6,164 KB
testcase_24 AC 25 ms
13,744 KB
testcase_25 AC 12 ms
10,992 KB
testcase_26 AC 20 ms
11,372 KB
testcase_27 AC 10 ms
7,448 KB
testcase_28 AC 11 ms
7,620 KB
testcase_29 AC 22 ms
13,748 KB
testcase_30 AC 21 ms
11,304 KB
testcase_31 AC 6 ms
6,064 KB
testcase_32 AC 7 ms
6,808 KB
testcase_33 AC 10 ms
7,452 KB
testcase_34 AC 24 ms
13,860 KB
testcase_35 AC 24 ms
13,804 KB
testcase_36 AC 11 ms
10,928 KB
testcase_37 AC 23 ms
13,740 KB
testcase_38 AC 3 ms
4,524 KB
testcase_39 AC 3 ms
4,440 KB
testcase_40 AC 15 ms
10,784 KB
testcase_41 AC 16 ms
13,800 KB
testcase_42 AC 14 ms
11,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘dame’ 内:
main.c:18:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   18 |         write(1,"-1",2);
      |         ^~~~~
main.c:19:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   19 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) {ulong _z=v;do*--wp=_z%10+48;while(_z/=10);}
#define rep(v,e) for(long v=0;v<e;++v)
#define rrep(v,e) for(long v=e;v--;)

typedef unsigned long ulong;
char wbuf[1<<25];

int x[200000];
int a[200000];
int v[1000001];
int q[0x40000];

void dame(){
	write(1,"-1",2);
	_exit(0);
}

int main(){
	long n;
	{
		char*mmap();
		char*rp=mmap(0l,1l<<25,1,2,0,0ll);
		n=rd();
		rep(i,n) x[i]=rd();
		rep(i,n){
			long y=rd();
			if(v[y]) dame();
			v[y]=~i;
		}
	}
	{
		long qr=0,qw=n;
		rrep(t,1000001){
			if(qr==qw) dame();
			long u=~q[qr++&0x3ffff];
			if(v[t]){
				if(u>=0) dame();
				u=~v[t];
			}
			if(u>=0&&!x[u]){
				a[u]=t;
			}
			else{
				if(u>=0){
					--x[u];
				}
				q[qw++&0x3ffff]=~u;
			}
		}
		if(qr!=qw) dame();
	}
	{
		char*wp=wbuf+sizeof wbuf;
		rrep(i,n){
			*--wp=' ';
			wt(a[i]);
		}
		write(1,wp,wbuf+sizeof wbuf-wp);
	}
	_exit(0);
}
0