QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21954#2833. HamiltonWhybullYMe#WA 3ms3704kbC++141.5kb2022-03-08 18:58:232022-05-08 04:19:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 04:19:50]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3704kb
  • [2022-03-08 18:58:23]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int n,a[2001][2001];
vector<pair<int,int> > v;
int main()
{
    while(cin>>n)
    {
        v.clear();
        for(int i=1;i<=n;++i)
            for(int j=1;j<=n;++j)
            {
                a[i][j]=getchar()^48;
                while(a[i][j]<0||a[i][j]>1)
                    a[i][j]=getchar()^48;
            }
        v.push_back({1,a[1][2]});
        v.push_back({2,a[2][3]});
        v.push_back({3,a[3][1]});
        for(int i=4;i<=n;++i)
        {
            int pos=0;
            for(int j=0;j<(int)v.size();++j)
                if(v[j].second^v[(j+1)%(i-1)].second)
                {
                    pos=j;
                    break;
                }
            int val=a[i][v[(pos+1)%(i-1)].first];
            if(val==v[pos].second)
            {
                v[(pos+1)%(i-1)].second=val;
                v.insert(v.begin()+(pos+2)%(i-1),{i,a[i][v[(pos+2)%(i-1)].first]});
            }
            else
            {
                v.insert(v.begin()+(pos+1)%(i-1),{i,val});
                v[pos].second=a[i][v[pos].first];
            }
        }
        int pos=0;
        for(int i=0;i<n;++i)
            if(v[i].second^v[(i+1)%n].second)
            {
                pos=i;
                break;
            }
        for(int i=0;i<n;++i)
            cout<<v[(i+pos)%n].first<<" ";
        cout<<'\n';
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3704kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

2 3 1 
1 2 4 3 

result:

wrong answer case #1: found 2 indices