QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#81844 | #2833. Hamilton | AHSFNU_team_0# | WA | 2ms | 3680kb | C++14 | 952b | 2023-02-26 14:54:45 | 2023-02-26 14:54:48 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int MxN=2002;
int n,at,bt;
int a[MxN],b[MxN];
char s[MxN][MxN];
template<class T>void read(T &x)
{
x=0;int f=0;char ch=getchar();
while(ch<'0' || ch>'9')f|=(ch=='-'),ch=getchar();
while(ch>='0' && ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
x=f? -x:x;return ;
}
int main()
{
for(;~scanf("%d",&n);)
{
at=bt=0;
for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
for(int i=1;i<=n;++i)
{
if(!at)
{
a[++at]=i;
continue;
}
if(!bt)
{
b[++bt]=i;
continue;
}
if(s[a[at]][i]=='0')
{
a[++at]=i;
continue;
}
if(s[b[bt]][i]=='1')
{
b[++bt]=i;
continue;
}
if(s[a[at]][b[bt]]=='1')b[++bt]=a[at],b[++bt]=i,--at;
else a[++at]=b[bt],a[++at]=i,--bt;
}
for(int i=1;i<=at;++i)printf("%d ",a[i]);
for(int i=1;i<=bt;++i)printf("%d ",b[i]);
puts("");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3680kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 1 3 4 2
result:
ok 2 cases.
Test #2:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 3 2 1 3 2 2 1 3 1 2 3
result:
ok 4 cases.
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3492kb
input:
4 0000 0000 0000 0000 4 0000 0001 0000 0100 4 0100 1010 0100 0000 4 0111 1000 1000 1000 4 0010 0011 1101 0110 4 0111 1011 1100 1100 4 0111 1011 1101 1110 4 0000 0011 0101 0110 4 0101 1010 0100 1000 4 0011 0011 1100 1100 4 0010 0001 1000 0100
output:
1 3 4 2 1 3 4 2 1 3 4 2 4 2 1 3 1 4 2 3 2 3 1 4 1 2 3 4 1 3 2 4 1 3 4 2 2 3 1 4 1 2 3 4
result:
wrong answer case #2: found 2 indices