QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375669 | #2833. Hamilton | 369Pai | WA | 0ms | 3636kb | C++14 | 818b | 2024-04-03 14:44:15 | 2024-04-03 14:44:15 |
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 x : p)cout << x << " ";
cout << "\n";
return 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0) , cout.tie(0);
while(cin >> n)Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
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: -100
Wrong Answer
time: 0ms
memory: 3636kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 1 2 3 1 2 3 1 2 3
result:
wrong answer case #3: found 2 indices