QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22345 | #2353. Maharajas are Going Home | s8194272# | WA | 877ms | 22568kb | C++14 | 2.8kb | 2022-03-09 15:47:59 | 2022-04-30 00:55:28 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define pb(x) push_back(x)
#define lowbit(x) (x&(-x))
#define fan(x) (((x-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
#define INF 0x3f3f3f3f
using namespace std;
inline int read()
{
int ans=0,f=1;
char c=getchar();
while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
return ans*f;
}
inline void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x/10) write(x/10);
putchar((char)(x%10)+'0');
}
template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a<b?a:b;}
template<typename T,typename TT> inline T Max(T a,TT b){return a<b?b:a;}
const int N=2005;
int t,n,sg[N][N];
struct Node
{
int x,y;
}a[N];
bitset<3200> p1[2][N],p2[2][N],p3,tmp;
inline void init(int x)
{
for(int i=1,I=1;i<=x;++i,I^=1)
{
p3.reset();
for(int j=1;j<=x;++j)
{
p1[I][j].reset();
p2[I][j].reset();
}
if(i==1)
{
p1[1][1][0]=1;
p2[1][1][0]=1;
p3[0]=1;
}
for(int j=1;j<=x;++j)
{
if(i==1&&j==1) continue;
tmp=(p1[I^1][j]|p2[I^1][j-1]|p3);
if(i>=3&&j>=2) tmp[sg[i-2][j-1]]=1;
if(j>=3&&i>=2) tmp[sg[i-1][j-2]]=1;
sg[i][j]=(~tmp)._Find_first();
p1[I][j]=p1[I^1][j];p1[I][j][sg[i][j]]=1;
p2[I][j]=p2[I^1][j-1];p2[I][j-1][sg[i][j]]=1;
p3[sg[i][j]]=1;
}
}
}
struct Ans
{
int x,y,z;
bool operator < (const Ans &p)const
{
if(x==p.x)
{
if(y==p.y)
return z<p.z;
return y<p.y;
}
return x<p.x;
}
}ans;
signed main()
{
init(2000);
t=read();
while(t--)
{
n=read();int SG=0;
for(int i=1;i<=n;++i)
{
a[i].x=read();
a[i].y=read();
SG^=sg[a[i].x][a[i].y];
}
if(SG==0)
puts("-1 -1 -1");
else
{
ans=(Ans){INF,INF,INF};
for(int i=1;i<=n;++i)
{
int SSG=(SG^sg[a[i].x][a[i].y]);
for(int j=1;j<a[i].x;++j)
if(sg[j][a[i].y]==SSG)
ans=min(ans,(Ans){i,j,a[i].y});
for(int j=1;j<a[i].y;++j)
if(sg[a[i].x][j]==SSG)
ans=min(ans,(Ans){i,a[i].x,j});
for(int j=1;j<min(a[i].x,a[i].y);++j)
if(sg[a[i].x-j][a[i].y-j]==SSG)
ans=min(ans,(Ans){i,a[i].x-j,a[i].y-j});
if(a[i].x>=3&&a[i].y>=2&&sg[a[i].x-2][a[i].y-1]==SSG) ans=min(ans,(Ans){i,a[i].x-2,a[i].y-1});
if(a[i].x>=2&&a[i].y>=3&&sg[a[i].x-1][a[i].y-2]==SSG) ans=min(ans,(Ans){i,a[i].x-1,a[i].y-2});
}
printf("%d %d %d\n",ans.x,ans.y,ans.z);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 877ms
memory: 22568kb
input:
3 5 2 3 3 2 3 3 3 3 3 3 1 2 4 2 1 1 3 2
output:
3 1 1 -1 -1 -1 2 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 843ms
memory: 22508kb
input:
1 1 1 1
output:
-1 -1 -1
result:
ok single line: '-1 -1 -1'
Test #3:
score: -100
Wrong Answer
time: 837ms
memory: 22484kb
input:
100 1 5 5 1 1 5 1 5 4 1 4 4 1 2 2 1 5 3 1 4 5 1 2 4 1 4 1 1 3 2 1 3 2 1 1 4 1 2 5 1 4 2 1 5 3 1 5 5 1 4 2 1 3 4 1 3 4 1 4 2 1 3 1 1 1 5 1 1 4 1 4 1 1 4 5 1 2 5 1 5 1 1 4 1 1 2 4 1 2 5 1 3 4 1 2 5 1 5 4 1 4 4 1 2 3 1 3 4 1 5 4 1 1 3 1 3 4 1 1 5 1 5 1 1 2 3 1 3 1 1 1 1 1 5 2 1 2 5 1 1 4 1 3 3 1 4 3 1 ...
output:
1 1 1 1 1 1 1 2 4 1 1 1 1 1 1 -1 -1 -1 1 2 4 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 4 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 2 4 1 2 4 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 4 1 2 4 1 1 1 1 1 1 -1 -1 -1 1 2 4 1 2 4 1 2 4 1 2 4 1 1 1 1 1 1 1 2 4 1 2 4 1 1 1 1 2 4 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 1 4 2 1 2 4 ...
result:
wrong answer 6th lines differ - expected: '1 4 2', found: '-1 -1 -1'