QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#375674 | #2833. Hamilton | 369Pai | WA | 0ms | 3508kb | C++14 | 1.0kb | 2024-04-03 14:46:59 | 2024-04-03 14:47:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2005;
int n , a[N][N];
int Solve()
{
for(int i = 1 ; i <= n ; i++)
{
string s; cin >> s;
for(int j = 0 ; j < n ; j++)
a[i][j + 1] = s[j] - '0';
}
vector<int>p = {1};
for(int i = 1 ; i < n ; i++)
{
int k = i + 1; bool ok = 0;
for(int j = 0 ; j < i ; j++)
{
int x = p[j] , y = p[(j + 1) % i] , z = p[(j + 2) % i];
if(a[x][y] != a[y][z])
{
if(a[y][k] == a[y][z])p.insert(p.begin() + (j + 1) % i, k);
else p.insert(p.begin() + (j + 2) % i , k);
ok = 1; break ;
}
}
if(!ok)p.push_back(k);
}
for(int j = 0 ; j < n ; j++)
{
int x = p[j] , y = p[(j + 1) % n] , z = p[(j + 2) % n];
if(a[x][y] != a[y][z])
{
for(int k = (j + 1) % n ; k < n ; k++)cout << p[k] << " ";
for(int k = 0 ; k <= j ; k++)cout << p[k] << " ";
break ;
}
}
cout << "\n";
return 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0) , cout.tie(0);
while(cin >> n)Solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3508kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
3 1 2
result:
wrong output format Unexpected end of file - int32 expected