QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#101958 | #6380. LaLa and Divination Magic | AFewSuns | WA | 2ms | 5800kb | C++14 | 2.2kb | 2023-05-01 22:04:00 | 2023-05-01 22:04:15 |
Judging History
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);
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: 2ms
memory: 5332kb
input:
2 1 1 0
output:
0
result:
ok Kout = 0, Kans = 0
Test #2:
score: 0
Accepted
time: 1ms
memory: 3620kb
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: 3472kb
input:
2 1 0 1
output:
0
result:
ok Kout = 0, Kans = 0
Test #4:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
2 1 0 1
output:
0
result:
ok Kout = 0, Kans = 0
Test #5:
score: 0
Accepted
time: 2ms
memory: 3432kb
input:
2 1 1 0
output:
0
result:
ok Kout = 0, Kans = 0
Test #6:
score: 0
Accepted
time: 2ms
memory: 5416kb
input:
2 1 0 1
output:
0
result:
ok Kout = 0, Kans = 0
Test #7:
score: 0
Accepted
time: 0ms
memory: 5644kb
input:
2 1 0 1
output:
0
result:
ok Kout = 0, Kans = 0
Test #8:
score: 0
Accepted
time: 0ms
memory: 5396kb
input:
2 1 1 0
output:
0
result:
ok Kout = 0, Kans = 0
Test #9:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 1 1
output:
1 0 0 4
result:
ok Kout = 1, Kans = 1
Test #10:
score: 0
Accepted
time: 0ms
memory: 5656kb
input:
1 1 0
output:
1 0 0 1
result:
ok Kout = 1, Kans = 1
Test #11:
score: 0
Accepted
time: 2ms
memory: 5528kb
input:
2 1 1 0
output:
0
result:
ok Kout = 0, Kans = 0
Test #12:
score: 0
Accepted
time: 0ms
memory: 5696kb
input:
2 1 1 0
output:
0
result:
ok Kout = 0, Kans = 0
Test #13:
score: 0
Accepted
time: 1ms
memory: 5528kb
input:
2 4 0111 0010
output:
15 0 0 1 0 1 1 0 1 3 0 2 1 0 2 3 0 2 4 0 3 1 0 3 3 1 2 3 1 2 4 1 3 3 1 3 2 2 2 4 2 3 2 2 3 4
result:
ok Kout = 15, Kans = 15
Test #14:
score: 0
Accepted
time: 2ms
memory: 3344kb
input:
2 1 1 0
output:
0
result:
ok Kout = 0, Kans = 0
Test #15:
score: 0
Accepted
time: 2ms
memory: 5524kb
input:
4 2 10 11 01 00
output:
0
result:
ok Kout = 0, Kans = 0
Test #16:
score: 0
Accepted
time: 2ms
memory: 5412kb
input:
2 1 1 0
output:
0
result:
ok Kout = 0, Kans = 0
Test #17:
score: 0
Accepted
time: 2ms
memory: 3580kb
input:
2 4 0010 1000
output:
15 0 1 1 0 1 2 0 2 1 0 2 4 0 3 1 0 3 2 1 1 1 1 2 1 1 2 3 1 3 1 1 3 3 1 3 2 2 3 1 2 3 2 3 3 1
result:
ok Kout = 15, Kans = 15
Test #18:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
2 5 11101 00000
output:
21 0 1 3 0 1 2 0 2 3 0 2 2 0 3 1 0 3 2 0 4 3 0 4 2 1 2 3 1 2 2 1 3 1 1 3 2 1 4 3 1 4 2 2 3 1 2 3 2 2 4 3 2 4 2 3 3 1 3 4 1 3 4 3
result:
ok Kout = 21, Kans = 21
Test #19:
score: 0
Accepted
time: 0ms
memory: 3444kb
input:
5 4 0010 1001 0011 0101 1011
output:
-1
result:
ok Kout = -1, Kans = -1
Test #20:
score: 0
Accepted
time: 2ms
memory: 5664kb
input:
3 2 01 00 10
output:
1 0 1 1
result:
ok Kout = 1, Kans = 1
Test #21:
score: 0
Accepted
time: 2ms
memory: 5800kb
input:
3 2 10 11 00
output:
1 0 1 2
result:
ok Kout = 1, Kans = 1
Test #22:
score: 0
Accepted
time: 2ms
memory: 3652kb
input:
2 1 0 1
output:
0
result:
ok Kout = 0, Kans = 0
Test #23:
score: -100
Wrong Answer
time: 2ms
memory: 3644kb
input:
3 27 111010110011101010011110110 010001110100000110100101101 000011111000000010011111001
output:
609 0 1 3 0 2 3 0 2 2 0 3 1 0 3 2 0 4 3 0 5 1 0 5 4 0 6 3 0 6 4 0 7 3 0 7 4 0 8 1 0 9 1 0 10 3 0 10 2 0 11 3 0 11 2 0 12 3 0 12 2 0 13 1 0 13 2 0 14 3 0 14 2 0 15 1 0 16 3 0 16 4 0 17 1 0 17 2 0 18 1 0 19 3 0 20 3 0 21 3 0 21 4 0 22 3 0 23 1 0 23 4 0 24 3 0 25 3 0 25 2 0 26 1 0 26 4 1 2 2 1 3 1 1 3 ...
result:
wrong answer The output contains more solutions than intended.