QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196325#2833. HamiltonCSU2023#WA 0ms3620kbC++141.7kb2023-10-01 15:52:552023-10-01 15:52:56

Judging History

This is the latest submission verdict.

  • [2023-10-01 15:52:56]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3620kb
  • [2023-10-01 15:52:55]
  • Submitted

answer

#include <bits/stdc++.h>

using std::ios;
using std::cin;
using std::cout;

const int N = 2005;
char c[N][N];
int n, p[N];

int main()
{
    freopen("g.in", "r", stdin);
    while (scanf("%d", &n) != EOF)
    {
        for (int i = 1; i <= n; ++i)
            scanf("%s", c[i] + 1);
        bool allsame = true;
        p[1] = 1; p[2] = 2;
        for (int i = 3; i <= n; ++i)
        {
            if (allsame)
            {
                if (c[i][p[i - 1]] != c[p[1]][p[2]])
                    allsame = false;
                p[i] = i;
            }
            else
            {
                int j;
                for (j = 2; j + 1 < i; ++j)
                    if (c[p[j - 1]][p[j]] != c[p[j]][p[j + 1]])
                        break ;
                if (c[p[j]][i] == c[p[j]][p[j + 1]])
                {
                    p[i] = i;
                    for (int k = i - 1; k >= j; --k)
                        std::swap(p[k], p[k + 1]);
                }
                else
                {
                    p[i] = i;
                    for (int k = i - 1; k > j; --k)
                        std::swap(p[k], p[k + 1]);
                }
                allsame = true;
                for (int j = 2; j < i; ++j)
                    if (c[p[j - 1]][p[j]] !=  c[p[j]][p[j + 1]])
                        allsame = false;
            }
        }
        if (c[p[1]][p[2]] == c[p[n]][p[1]])
        {
            int temp = p[n];
            for (int i = n - 1; i >= 1; --i)
                p[i + 1] = p[i];
            p[1] = temp;
        }
        for (int i = 1; i <= n; ++i)
            printf("%d ", p[i]);
        putchar('\n');
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:


result:

wrong output format Unexpected end of file - int32 expected