QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#377150#2833. HamiltonJerrywangWA 0ms3960kbC++141.1kb2024-04-04 23:18:102024-04-04 23:18:11

Judging History

你现在查看的是最新测评结果

  • [2024-04-04 23:18:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3960kb
  • [2024-04-04 23:18:10]
  • 提交

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