QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213572 | #6552. Good and Lucky Matrices | ucup-team1004# | 0 | 186ms | 5616kb | C++14 | 2.0kb | 2023-10-14 14:56:02 | 2023-10-14 14:56:02 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__uint128_t;
const int N=2e3+5,M=N*100+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-6;const int INF=1e9+7;mt19937 rnd(263082);
int n;char s[N],c[N];
bitset<N> B[N],C[N],A[N];
int v1[N],t1[N],v2[N],t2[N];
void Solve(){
int i,j;scanf("%s",s+1);scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%s",c+1);
for(j=1;j<=n;j++) A[i][j]=c[j]-'0';
}
if(s[1]=='l'){
Me(v1,0);Me(v2,0);Me(t1,0);Me(t2,0);
for(i=1;i<=n;i++){
B[i].reset();
for(j=1;j<=n;j++) if(A[i][j]&&v1[j]) B[i]^=C[v1[j]];
int R=1;for(j=1;j<=n;j++) if(!v1[j]) {
while(v2[R]) R++;B[i][R]=B[i][R]^A[i][j];R++;
}
for(j=1;j<=n;j++) if(A[i][j]&&!v1[j]){v1[j]=i;t1[i]=j;break;}
C[i]=B[i];for(j=1;j<i;j++) if(C[i][t2[j]]) C[i]^=C[j];
for(j=1;j<=n;j++) if(C[i][j]) {v2[j]=i;t2[i]=j;break;}
}
printf("%d\n",n);
for(i=1;i<=n;printf("\n"),i++) for(j=1;j<=n;j++) printf("%d",(int) B[i][j]);
}else{
Me(v1,0);Me(v2,0);Me(t1,0);Me(t2,0);
for(i=1;i<=n;i++){
B[i].reset();
for(j=1;j<=n;j++) if(A[i][j]&&v2[j]) B[i]^=C[v2[j]];
int R=1;for(j=1;j<=n;j++) if(!v2[j]) {
while(v1[R]) R++;B[i][R]=B[i][R]^A[i][j];R++;
}
for(j=1;j<=n;j++) if(B[i][j]&&!v1[j]){v1[j]=i;t1[i]=j;break;}
C[i]=A[i];for(j=1;j<i;j++) if(C[i][t2[j]]) C[i]^=C[j];
for(j=1;j<=n;j++) if(C[i][j]) {v2[j]=i;t2[i]=j;break;}
}
printf("%d\n",n);
for(i=1;i<=n;printf("\n"),i++) for(j=1;j<=n;j++) printf("%d",(int) B[i][j]);
}
}
int main(){
int t=1;
scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4076kb
First Run Input
3 lucky 2 11 11 good 2 11 01 lucky 2 01 10
First Run Output
2 11 10 2 11 01 2 01 10
Second Run Input
3 good 2 11 10 lucky 2 11 01 good 2 01 10
Second Run Output
2 11 11 2 11 01 2 01 10
result:
ok 9 lines
Test #2:
score: 100
Accepted
time: 0ms
memory: 4080kb
First Run Input
3 good 2 11 10 lucky 2 11 01 good 2 01 10
First Run Output
2 11 11 2 11 01 2 01 10
Second Run Input
3 lucky 2 11 11 good 2 11 01 lucky 2 01 10
Second Run Output
2 11 10 2 11 01 2 01 10
result:
ok 9 lines
Test #3:
score: 100
Accepted
time: 167ms
memory: 5536kb
First Run Input
1 good 2000 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
First Run Output
2000 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Input
1 lucky 2000 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Output
2000 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 2001 lines
Test #4:
score: 100
Accepted
time: 163ms
memory: 5608kb
First Run Input
1 lucky 2000 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
First Run Output
2000 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Input
1 good 2000 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Output
2000 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 2001 lines
Test #5:
score: 100
Accepted
time: 167ms
memory: 5504kb
First Run Input
1 good 2000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
First Run Output
2000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Input
1 lucky 2000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Output
2000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 2001 lines
Test #6:
score: 100
Accepted
time: 166ms
memory: 5556kb
First Run Input
1 lucky 2000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
First Run Output
2000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Input
1 good 2000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
Second Run Output
2000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok 2001 lines
Test #7:
score: 0
Wrong Answer
time: 186ms
memory: 5616kb
First Run Input
1 lucky 2000 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
First Run Output
2000 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
Second Run Input
1 good 2000 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
Second Run Output
2000 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
wrong answer 4th lines differ - expected: '111111111111111111111111111111...1111111111111111111111111111111', found: '110000000000000000000000000000...0000000000000000000000000000000'