QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#101955#6380. LaLa and Divination MagicAFewSunsWA 2ms3540kbC++142.1kb2023-05-01 21:59:442023-05-01 21:59:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-01 21:59:47]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3540kb
  • [2023-05-01 21:59:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
bitset<2020> b[2020][2];
bitset<4040> f[4040];
vector<pair<pair<ll,ll>,ll> > ans;
ll n,m,res=0;
char s[2020];
void dfs(ll now,bitset<4040> ck){
	if(((ck<<n)&ck).any()) return;
	if(now==m){
		res++;
		if(res>n){
			write(-1);
			exit(0);
		}
		return;
	}
	now++;
	if(!ck[now+n]) dfs(now,ck|f[now]);
	if(!ck[now]) dfs(now,ck|f[now+n]);
}
int main(){
	n=read();
	m=read();
	fr(i,1,n){
		scanf("%s",s+1);
		fr(j,1,m) b[j][s[j]-'0'][i]=1;
	}
	fr(i,1,m){
		fr(j,i,m){
			fr(x,0,1){
				fr(y,0,1){
					if((b[i][x^1]&b[j][y^1]).any()) continue;
					f[i+(x^1)*n][j+y*n]=1;
					f[j+(y^1)*n][i+x*n]=1;
					ans.push_back(MP(MP(i,j),x+y*2+1));
				}
			}
		}
	}
	bitset<4040> tmp;
	tmp.reset();
	dfs(0,tmp);
	writeln(ans.size());
	fr(i,0,(ll)ans.size()-1) pf("%lld %lld %lld\n",ans[i].fir.fir,ans[i].fir.sec,ans[i].sec);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3540kb

input:

2 1
1
0

output:

2
1 1 3
1 1 2

result:

wrong answer Integer parameter [name=x] equals to 1, violates the range [0, 0]