QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#101959#6380. LaLa and Divination MagicAFewSunsWA 2ms5784kbC++142.2kb2023-05-01 22:05:282023-05-01 22:05:32

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 22:05:32]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5784kb
  • [2023-05-01 22:05:28]
  • 提交

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(i==j&&x!=y) continue;
					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-1,j-1),x+y*2+1));
				}
			}
		}
	}
	fr(i,1,2*m) f[i][i]=1;
	bitset<4040> tmp;
	tmp.reset();
	dfs(0,tmp);
	if(res<n){
		write(-1);
		return 0;
	}
	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: 100
Accepted
time: 0ms
memory: 5532kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #2:

score: 0
Accepted
time: 1ms
memory: 5784kb

input:

3 3
101
011
111

output:

6
0 1 4
0 2 3
0 2 4
1 2 3
1 2 4
2 2 4

result:

ok Kout = 6, Kans = 6

Test #3:

score: 0
Accepted
time: 2ms
memory: 3284kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #4:

score: 0
Accepted
time: 2ms
memory: 3624kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #5:

score: 0
Accepted
time: 2ms
memory: 5528kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #6:

score: 0
Accepted
time: 2ms
memory: 5652kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #7:

score: 0
Accepted
time: 2ms
memory: 5328kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #8:

score: 0
Accepted
time: 2ms
memory: 3356kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #9:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

1 1
1

output:

1
0 0 4

result:

ok Kout = 1, Kans = 1

Test #10:

score: 0
Accepted
time: 1ms
memory: 5600kb

input:

1 1
0

output:

1
0 0 1

result:

ok Kout = 1, Kans = 1

Test #11:

score: 0
Accepted
time: 1ms
memory: 5648kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #12:

score: 0
Accepted
time: 1ms
memory: 5600kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #13:

score: -100
Wrong Answer
time: 0ms
memory: 5416kb

input:

2 4
0111
0010

output:

-1

result:

wrong answer Jury has a solution while the participant doesn't, Kans = 15