QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#375629 | #2833. Hamilton | fzx | WA | 1ms | 3672kb | C++14 | 1.3kb | 2024-04-03 14:21:28 | 2024-04-03 14:21:28 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=2e3+5;
int n,p3[INF],p[INF];
char c[INF][INF];
void solve() {
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
cin>>c[i][j];
p[1]=1;p[2]=2;p[3]=3;
for (int i=4;i<=n;i++) {
int fl=0;
for (int j=1;j<i;j++)
if (c[p[j-1<1?i-1:j-1]][p[j]]!=c[p[j]][p[(j+1>=i)?1:j+1]]) {
if (c[i][p[j]]==c[p[j]][p[(j+1>=i)?1:j+1]]) {
p3[0]=0;
for (int k=1;k<=j;k++)
p3[++p3[0]]=p[k];
p3[++p3[0]]=i;
for (int k=j+1;k<i;k++) p3[++p3[0]]=p[k];
for (int i=1;i<=p3[0];i++) p[i]=p3[i];
fl=1;
break;
}
else {
p3[0]=0;
for (int k=1;k<j;k++)
p3[++p3[0]]=p[k];
p3[++p3[0]]=i;
for (int k=j;k<i;k++)
p3[++p3[0]]=p[k];
for (int i=1;i<=p3[0];i++) p[i]=p3[i];
fl=1;
break;
}
}
if (!fl) p[i]=i;
}
int fl2=0;
for (int j=1;j<=n;j++)
if (c[p[j-1<1?n:j-1]][p[j]]!=c[p[j]][p[(j+1>n)?1:j+1]]) {
for (int u=j;u<=n;u++) cout<<p[u]<<" ";
for (int u=1;u<j;u++) cout<<p[u]<<" ";
cout<<"\n";
fl2=1;
return ;
}
if (!fl2) {
for (int u=1;u<=n;u++)
cout<<p[u]<<" ";
cout<<"\n";
}
return ;
}
signed main()
{
ios::sync_with_stdio(false);
while (cin>>n) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3672kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 1 2 3 4
result:
ok 2 cases.
Test #2:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 1 2 3 2 3 1 1 2 3
result:
ok 4 cases.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3636kb
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 2 3 4 1 2 3 4 1 2 3 4 2 4 3 1 1 4 2 3 3 4 1 2 1 2 3 4 2 4 3 1 1 4 2 3 4 1 2 3 1 4 2 3
result:
wrong answer case #9: found 3 indices