QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#377150 | #2833. Hamilton | Jerrywang | WA | 0ms | 3960kb | C++14 | 1.1kb | 2024-04-04 23:18:10 | 2024-04-04 23:18:11 |
Judging History
answer
// Title: Hamilton
// Source: QOJ2833
// Author: Jerrywang
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define ll long long
#define rep(i, s, t) for(int i=s; i<=t; ++i)
#define debug(x) cerr<<#x<<":"<<x<<endl;
const int N=2005;
using namespace std;
int n, g[N][N]; vector<int> a;
void ins(int i, int x)
{
a.insert(a.begin()+i, x);
}
void solve()
{
rep(i, 1, n) rep(j, 1, n) scanf("%1d", &g[i][j]);
a.clear();
rep(i, 0, 2) a.push_back(i);
rep(i, 3, n)
{
int k=0;
rep(j, 2, i-2)
{
if(g[a[j-1]][a[j]] && !g[a[j]][a[j+1]])
{
k=j; break;
}
}
if(!k)
{
a.push_back(i); continue;
}
if(g[a[k]][i]==0) ins(k, i);
else ins(k+1, i);
}
rep(i, 1, n) printf("%d ", a[i]);
puts("");
}
int main()
{
#ifdef Jerrywang
freopen("E:/OI/in.txt", "r", stdin);
#endif
while(~scanf("%d", &n)) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3960kb
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: 3960kb
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