QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#359210 | #6552. Good and Lucky Matrices | Kevin5307 | 0 | 31ms | 13116kb | C++20 | 2.4kb | 2024-03-20 14:44:56 | 2024-03-20 14:44:56 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
namespace Lucky
{
string grid[2020];
int x[2020];
bool vis[2020];
bitset<2020> ans[2020];
int ind[2020];
void solve()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
cin>>grid[i];
for(int i=0;i<n;i++)
{
ans[i]=0;
x[i]=vis[i]=ind[i]=0;
}
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(grid[i][j]=='1'&&!vis[j])
{
vis[j]=1;
x[i]=j;
ind[j]=i;
break;
}
for(int i=0;i<n;i++)
for(int j=x[i];j<n;j++)
ans[i][j]=grid[i][j]^48;
for(int i=0;i<n;i++)
for(int j=0;j<x[i];j++)
if(grid[i][j]=='1')
ans[i]^=ans[ind[j]];
printf("%d\n",n);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
putchar(ans[i][j]^48);
putchar(10);
}
return ;
}
}
namespace Good
{
string grid[2020];
bitset<2020> bs[2020],B[2020];
bool flag[2020];
char ans[2020][2020];
void solve()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
ans[i][j]='0';
for(int i=0;i<n;i++)
{
cin>>grid[i];
for(int j=0;j<n;j++)
bs[i][j]=grid[i][j]^48;
B[i]=0;
flag[i]=0;
}
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(bs[i][j])
{
if(!flag[j])
{
B[j]=bs[i];
for(int x=j;x<n;x++)
ans[i][x]=bs[i][x]^48;
flag[j]=1;
break;
}
bs[i]^=B[j];
ans[i][j]='1';
}
printf("%d\n",n);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
putchar(ans[i][j]);
putchar(10);
}
return ;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
string type;
cin>>type;
if(type=="lucky")
Lucky::solve();
else
Good::solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5936kb
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: 1ms
memory: 5900kb
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: 24ms
memory: 13096kb
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: 23ms
memory: 13040kb
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: 22ms
memory: 13068kb
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: 23ms
memory: 13116kb
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: 31ms
memory: 13096kb
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: '011111111111111111111111111111...1111111111111111111111111111111'