QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#442520 | #8748. 简单博弈 | union_of_britain# | RE | 0ms | 0kb | C++14 | 4.1kb | 2024-06-15 12:34:08 | 2024-06-15 12:34:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define VI vector<int>
int f[505][505][8][8],vis[114514];
inline int mex(const VI &V){
for(auto u:V)vis[u]=1;
int res=0;
for(;vis[res];++res);
for(auto u:V)vis[u]=0;
return res;
}
int N=500;
int SW(int S,int x,int y){
S=S+(((S>>x)&1)<<y)+(((S>>y)&1)<<x)-(((S>>x)&1)<<x)-(((S>>y)&1)<<y);
return S;
}
void getS(int &x,int &y){
if(x==2){
SW(x,0,1);SW(y,0,1);
}else if(x==4){
SW(x,0,2);SW(y,0,2);
}else if(x==6){
SW(x,0,2);SW(y,0,2);
}else if(x==5){
SW(x,2,1);SW(y,2,1);
}
}
pair<int,int> gs[8][8];
int f2[505][505][8][4],f4[505][505][4][4],f5[505][505][4][2];
signed main(){
for(int i=0;i<8;i++)for(int j=0;j<8;j++){
int x=i,y=j;getS(x,y);
gs[i][j]={x,y};
}
for(int n=0;n<=N;n++){
for(int m=0;m<=N;m++){
for(int S1=7;S1>=0;S1--){
for(int S2=7;S2>=0;S2--){
if(make_pair(S1,S2)!=gs[S1][S2])continue;
VI V(8,114513);
if(n>0&&(S2!=7||m>0))V[0]=f[n-1][m][S1][S2];
if(m>0&&(S1!=7||n>0))V[1]=f[n-1][m-1][S1][S2];
if(!(S1&1)&&!(m==0&&(S2&2)&&(S2&4)))V[2]=f[n][m][gs[S1|1][S2].first][gs[S1|1][S2].second];
if(!(S2&1)&&!(n==0&&(S1&2)&&(S1&4)))V[3]=f[n][m][gs[S1][S2|1].first][gs[S1][S2|1].second];
if(!(S1&2)&&!(m==0&&(S2&1)&&(S2&4)))V[4]=f[n][m][gs[S1|2][S2].first][gs[S1|2][S2].second];
if(!(S2&2)&&!(n==0&&(S1&1)&&(S1&4)))V[5]=f[n][m][gs[S1][S2|2].first][gs[S1][S2|2].second];
if(!(S1&4)&&!(m==0&&(S2&1)&&(S2&2)))V[6]=f[n][m][gs[S1|4][S2].first][gs[S1|4][S2].second];
if(!(S2&4)&&!(n==0&&(S1&1)&&(S1&2)))V[7]=f[n][m][gs[S1][S2|4].first][gs[S1][S2|4].second];
f[n][m][S1][S2]=mex(V);
}
}
}
}
for(int n=0;n<=N;n++){
for(int m=0;m<=N;m++){
for(int S1=3;S1>=0;S1--){
for(int S2=7;S2>=0;S2--){
if(make_pair(S1,S2)!=gs[S1][S2])continue;
VI V(7,114513);
if(n>0&&(S2!=7||m>0))V[0]=f2[n-1][m][S1][S2];
if(m>0&&(S1!=3||n>0))V[1]=f2[n-1][m-1][S1][S2];
if(!(S1&1)&&!(m==0&&(S2&2)))V[2]=f2[n][m][gs[S1|1][S2].first][gs[S1|1][S2].second];
if(!(S2&1)&&!(n==0&&(S1&2)))V[3]=f2[n][m][gs[S1][S2|1].first][gs[S1][S2|1].second];
if(!(S1&2)&&!(m==0&&(S2&1)&&(S2&4)))V[4]=f2[n][m][gs[S1|2][S2].first][gs[S1|2][S2].second];
if(!(S2&2)&&!(n==0&&(S1&1)))V[5]=f2[n][m][gs[S1][S2|2].first][gs[S1][S2|2].second];
if(!(S2&4)&&!(n==0&&(S1&1)))V[6]=f2[n][m][gs[S1][S2|4].first][gs[S1][S2|4].second];
f2[n][m][S1][S2]=mex(V);
}
}
}
}
for(int n=0;n<=N;n++){
for(int m=0;m<=N;m++){
for(int S1=3;S1>=0;S1--){
for(int S2=3;S2>=0;S2--){
if(make_pair(S1,S2)!=gs[S1][S2])continue;
VI V(6,114513);
if(n>0&&(S2!=3||m>0))V[0]=f4[n-1][m][S1][S2];
if(m>0&&(S1!=3||n>0))V[1]=f4[n-1][m-1][S1][S2];
if(!(S1&1)&&!(m==0&&(S2&2)))V[2]=f4[n][m][gs[S1|1][S2].first][gs[S1|1][S2].second];
if(!(S2&1)&&!(n==0))V[3]=f4[n][m][gs[S1][S2|1].first][gs[S1][S2|1].second];
if(!(S1&2)&&!(m==0))V[4]=f4[n][m][gs[S1|2][S2].first][gs[S1|2][S2].second];
if(!(S2&2)&&!(n==0&&(S1&1)))V[5]=f4[n][m][gs[S1][S2|2].first][gs[S1][S2|2].second];
f4[n][m][S1][S2]=mex(V);
}
}
}
}
for(int n=0;n<=N;n++){
for(int m=0;m<=N;m++){
for(int S1=3;S1>=0;S1--){
for(int S2=1;S2>=0;S2--){
VI V(4,114513);
if(n>0&&(S2!=3||m>0))V[0]=f5[n-1][m][S1][S2];
if(m>0&&(S1!=1||n>0))V[1]=f5[n][m-1][S1][S2];
if(S1<3&&(m>0))V[2]=f5[n][m][S1+1][S2];
if(S2<1&&(S1<3||m>0))V[3]=f5[n][m][S1][S2+1];
f5[n][m][S1][S2]=mex(V);
}
}
}
}
int n,r=0,m;
cin>>n>>m;
while(n--){
int x[3],y[3];
set<int> xi,yi;
for(int i=0;i<3;i++){
cin>>x[i]>>y[i];
xi.insert(x[i]),yi.insert(y[i]);
}
if(xi.size()==3&&yi.size()==3){
r^=f[n-3][m-3][0][0];
}if(xi.size()==3&&yi.size()==2){
r^=f2[n-3][m-2][0][0];
}if(xi.size()==2&&yi.size()==3){
r^=f2[m-3][n-2][0][0];
}if(xi.size()==2&&yi.size()==2){
r^=f4[n-2][m-2][0][0];
}if(xi.size()==3&&yi.size()==1){
r^=f4[n-3][m-1][0][0];
}if(xi.size()==1&&yi.size()==3){
r^=f4[m-3][n-1][0][0];
}
}
if(!r)cout<<"OvO"<<endl;
else cout<<"QAQ"<<endl;
return 0;
}
详细
Test #1:
score: 0
Runtime Error
input:
100000 215 4 6 1 59 1 71 4 1 482 1 311 1 381 1 26 3 428 3 81 2 359 1 310 222 220 108 40 16 2 11 79 4 223 4 73 4 103 3 51 214 442 174 261 186 418 202 379 146 464 61 193 85 102 117 206 3 1 3 1 2 1 1 1 357 356 199 222 97 15 257 15 30 2 28 2 4 1 12 2 308 308 32 110 56 157 234 171 347 346 243 89 166 140 ...