QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22481#2353. Maharajas are Going Homeha114514ha#WA 299ms26152kbC++205.9kb2022-03-09 19:03:512022-04-30 01:11:38

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 01:11:38]
  • 评测
  • 测评结果:WA
  • 用时:299ms
  • 内存:26152kb
  • [2022-03-09 19:03:51]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#include<ctime>
#include<random>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define bc(x) __builtin_popcount(x)
#define re register
#define il inline
#define pii pair<int,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
// #pragma GCC optimize(3)
//#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
namespace IO_BUFF{
	mt19937 rnd(time(0)^(ll)(new char));
	int rend(int x){
		return rnd()%x+1;
	}
	void rendom_shuffle(int *a,int len){
		shuffle(a+1,a+len+1,rnd);
	}
	const int BS=(1<<24)+5;char Buffer[BS],*HD,*TL;
	inline int gc(){
	    if(HD==TL) TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);
	    return (HD==TL)?EOF:*HD++;
	}
	inline int inn(){
	    int x,ch,s=1;while((ch=gc())<'0'||ch>'9')if(ch=='-')s=-1;x=ch^'0';
	    while((ch=gc())>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^'0');return x*s;
	}
	char ssss[19999999],tttt[20];int ssl,ttl;
    inline int print(int x)
    {
        if(x<0)ssss[++ssl]='-',x=(-x);
		if(!x) ssss[++ssl]='0';for(ttl=0;x;x/=10) tttt[++ttl]=char(x%10+'0');
        for(;ttl;ttl--) ssss[++ssl]=tttt[ttl];return ssss[++ssl]='\n';
    }
	inline int Flush(){return fwrite(ssss+1,sizeof(char),ssl,stdout),ssl=0,0;}
	int read(){
		char c=getchar();int x=1;int s=0;
		while(c<'0' || c>'9'){if(c=='-')x=-1;c=getchar();}
		while(c>='0' && c<='9'){
			s=s*10+c-'0';c=getchar();
		}
		return s*x;
	}
}using namespace IO_BUFF;
/*namespace CFConTest{
	const int mod=998244353;
	inline int add(const int &x,const int &y){
		return (x+y>=mod?x+y-mod:x+y);
	}
	inline int del(const int &x,const int &y){
		return (x-y<0?x-y+mod:x-y);
	}
	int ksm(int x,int k){
		int base=1;
		while(k){
			if(k&1)base=1ll*base*x%mod;
			k>>=1;
			x=1ll*x*x%mod;
		}
		return base;
	}
};
using namespace CFConTest;*/
const int N=2005;
const int M=2000;
#define bitSEET hh;
namespace MYbitset{
	ull mip[65];
	ull summ=0;
   	int len;
	struct hh{
		ull bit[4000/64+5];
		hh() {memset(bit,0,sizeof(bit));}
		void clear(){
			memset(bit,0,sizeof(bit));
		}
		void set0(int x){
			bit[x>>6]&=~mip[x&63];
		}
		void set1(int x){
			bit[x>>6]|=mip[x&63];
		}
		bool operator [](int x){
			return (bit[x>>6]>>(x&63))&1;
		}
		int count(){
			int tmp=0;
			for(int i=0;i<len;i++)tmp+=__builtin_popcountll(bit[i]);
			return tmp;
		}
		hh operator & (const hh &b)const{
			hh tmp;
			for(int i=0;i<len;i++)tmp.bit[i]=bit[i]&b.bit[i];return tmp;
		}
		void operator &= (const hh &b){
			for(int i=0;i<len;i++)bit[i]&=b.bit[i];
		}
		hh operator | (const hh &b)const{
			hh tmp;
			for(int i=0;i<len;i++)tmp.bit[i]=bit[i]|b.bit[i];return tmp;
		}
		void operator |= (const hh &b){
			for(int i=0;i<len;i++)bit[i]|=b.bit[i];
		}
		hh operator ^ (const hh &b)const{
			hh tmp;
			for(int i=0;i<len;i++)tmp.bit[i]=bit[i]^b.bit[i];return tmp;
		}
		void operator ^= (const hh &b){
			for(int i=0;i<len;i++)bit[i]^=b.bit[i];
		}
		int first0(){
			for(int i=0;i<len;i++){
				if(bit[i]!=summ){
					const ull h=(~bit[i]);
					return i*64+__builtin_ffsll(h&(-h))-1;
				}
			}
			return 1e9;
		}
	};
	void preweak(){
		for(int i=0;i<=63;i++)mip[i]=(1ull<<i);
		for(int i=0;i<=63;i++)summ|=(1ull<<i);
	}
};
using namespace MYbitset;
hh f[N],g[N],h[2*N+100];
int sg[N+100][N+100];
int T,n,x,y,xx[N],yy[N];
int md[40],cd[40];
void check(){
	for(int i=1;i<=3;i++){
		if(md[i]<cd[i])return;
		if(md[i]>cd[i]){
			for(int k=1;k<=3;k++)md[k]=cd[k];
			return ;
		}
	}
	return;
}
int main(){
	#ifdef newbiewzs
		freopen("data.in","r",stdin);
	#else
	#endif
	preweak();len=4000/64+2;
	for(int i=1;i<=2000;i++){
		for(int k=1;k<=2000;k++){
			hh tmp=f[i]|g[k]|h[k-i+N];
			if(i>2 && k>1)tmp.set1(sg[i-2][k-1]);
			if(i>1 && k>2)tmp.set1(sg[i-1][k-2]);
			sg[i][k]=tmp.first0();
			f[i].set1(sg[i][k]);
			g[k].set1(sg[i][k]);
			h[k-i+N].set1(sg[i][k]);
		}
	}
	/*for(int i=1;i<=4;i++){
		for(int k=1;k<=4;k++){
			cout<<sg[i][k]<<" ";
		}
		cout<<'\n';
	}*/
	T=read();
	while(T--){
		n=read();
		int ans=0;
		for(int i=1;i<=n;i++){
			x=read();y=read();
			xx[i]=x;yy[i]=y;
			ans^=sg[x][y];
		}
		if(!ans){
			puts("-1 -1 -1");
		}
		else {
			md[1]=md[2]=md[3]=1e9;
			bool flag=0;
			for(int i=1;i<=n;i++){
				int ans=0;
				for(int k=1;k<yy[i];k++){
					ans=sg[xx[i]][k];
					for(int j=1;j<=n;j++){
						if(j!=i)ans^=sg[xx[j]][yy[j]];
					}
					if(ans)continue;
					cd[1]=i;cd[2]=xx[i];cd[3]=k;
					check();
				}
				for(int k=1;k<xx[i];k++){
					ans=sg[k][yy[i]];
					for(int j=1;j<=n;j++){
						if(j!=i)ans^=sg[xx[j]][yy[j]];
					}
					if(ans)continue;
					cd[1]=i;cd[2]=k;cd[3]=yy[i];
					check();
				}
				for(int k=1;k<min(xx[i],yy[i]);k++){
					ans=sg[xx[i]-k][yy[i]-k];
					for(int j=1;j<=n;j++){
						if(j!=i)ans^=sg[xx[j]][yy[j]];
					}
					if(ans)continue;
					cd[1]=i;cd[2]=xx[i]-k;cd[3]=yy[i]-k;
					check();
				}
				if(xx[i]>1 && yy[i]>2){
					ans=sg[xx[i]-1][yy[i]-2];
					for(int j=1;j<=n;j++){
						if(j!=i)ans^=sg[xx[j]][yy[j]];
					}
					if(ans)continue;
					cd[1]=i;cd[2]=xx[i]-1;cd[3]=yy[i]-2;
					check();
				}
				if(xx[i]>2 && yy[i]>1){
					ans=sg[xx[i]-2][yy[i]-1];
					for(int j=1;j<=n;j++){
						if(j!=i)ans^=sg[xx[j]][yy[j]];
					}
					if(ans)continue;
					cd[1]=i;cd[2]=xx[i]-2;cd[3]=yy[i]-1;
					check();
				}
			}
			for(int i=1;i<=3;i++){
				if(md[i]==1e9){
					while(1);
				}
				cout<<md[i]<<" ";
			}
			cout<<'\n';
		//	puts("2 3 3");
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 257ms
memory: 25408kb

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: 293ms
memory: 26152kb

input:

1
1
1 1

output:

-1 -1 -1

result:

ok single line: '-1 -1 -1'

Test #3:

score: -100
Wrong Answer
time: 299ms
memory: 26144kb

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 4 2 
1 4 2 
-1 -1 -1
1 1 1 
1 1 1 
1 1 1 
1 1 1 
1 2 4 
-1 -1 -1
1 4 2 
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 4 2 
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...

result:

wrong answer 7th lines differ - expected: '1 2 4', found: '1 4 2 '