結果

問題 No.2727 Tetrahedron Game
ユーザー tailstails
提出日時 2024-04-16 18:13:28
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,766 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 28,764 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 18:13:29
合計ジャッジ時間 957 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 11 ms
5,376 KB
testcase_04 AC 11 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 11 ms
5,376 KB
testcase_07 AC 10 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 10 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:88:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
   88 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:89:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   89 |         _exit(0);
      |         ^~~~~
main.c:89:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rd_signed() ({int _s=*rp=='-'&&++rp,_v=rd();_s?-_v:_v;})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define reps(v,s,e) for(typeof(e) v=s;v<e;++v)
#define rrep(v,e) for(typeof(e) v=e;v--;)
#define chmin(v,a) (v=v<=a?v:a)
#define chmax(v,a) (v=v>=a?v:a)

char wbuf[1<<25];
int a[10000];

int main(){
	char*wp=wbuf;
	rd_init();
	int t=rd();
	while(t--){
		int n=rd();
		int k=rd();
		long h;
		{
			long p11=rd_signed(),p12=rd_signed(),p13=rd_signed();
			long p21=rd_signed(),p22=rd_signed(),p23=rd_signed();
			long p31=rd_signed(),p32=rd_signed(),p33=rd_signed();
			h=p11*(p22*p33-p23*p32)+p12*(p23*p31-p21*p33)+p13*(p21*p32-p22*p31);
			if(h<0) h=-h;
		}
		rep(i,n){
			a[i]=rd();
		}
		char*s=rp+n;
		rp=s+1;
		if(h){
			h%=606;
			int z;
			if(n==1){
				int b=h*(a[0]+1)%606;
				z=
					s[-1]=='K'?
						h%6==0&&h>=k*6?1:
						b%6==0&&b>=k*6?1:
						h%6?0:-1
					:
						h%6==0&&h<k*6?-1:
						b%6==0&&b<k*6?-1:
						h%6?0:1;
			}else{
				char d[606];
				rep(j,101){
					d[j*6+0]=j>=k?1:-1;
					d[j*6+1]=0;
					d[j*6+2]=0;
					d[j*6+3]=0;
					d[j*6+4]=0;
					d[j*6+5]=0;
				}
				rrep(i,n){
					char e[606];
					rep(j,606){
						e[j]=d[j];
					}
					int b=a[i]+1;
					if(*--s=='K'){
						int c=b;
						reps(j,1,606){
							chmax(d[j],e[c]);
							c+=b; c-=c<606?0:606;
						}
					}else{
						int c=b;
						reps(j,1,606){
							chmin(d[j],e[c]);
							c+=b; c-=c<606?0:606;
						}
					}
				}
				z=d[h];
			}
			*wp++=z<0?'P':z==0?'D':'K';
		}else{
			*wp++='D';
		}
		*wp++='\n';
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0