QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56757#2833. HamiltonindogentWA 3ms3152kbC++1.4kb2022-10-21 15:38:512022-10-21 15:38:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-21 15:38:54]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3152kb
  • [2022-10-21 15:38:51]
  • 提交

answer

#include <cstdio>
#include <cstdlib>
#include <vector>

const int N = 2000 + 10;

char s[N][N];

int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; ++i)
      scanf("%s", s[i]);
    std::vector<int> path = {0, 1, 2};
    std::vector<char> col = {s[0][1], s[1][2], s[2][0]};
    for (int i = 3; i < n; ++i) {
      int x = 0, y = 1, z = 2;
      for (size_t j = 0; j < path.size(); ++j) {
        if (col[j] != col[(j + 1) % path.size()]) {
          x = j;
          y = (j + 1) % path.size();
          z = (j + 2) % path.size();
          break;
        }
      }
      char t = s[i][path[y]];
      if (t == col[x]) {
        path.insert(path.begin() + z, i);
        col[y] = col[x];
        col.insert(col.begin() + z, s[i][path[z + 1]]);
      } else {
        path.insert(path.begin() + y, i);
        col.insert(col.begin() + y, t);
        col[x] = s[i][path[(y - 1 + path.size()) % path.size()]];
      }
      for (size_t j = 0; j < path.size(); ++j)
      	printf("%d, ", path[j] + 1);
    	puts("");
    }
    int x = 0;
    for (size_t j = 0; j < path.size(); ++j) {
      if (col[j] != col[(j + 1) % path.size()]) {
        x = j;
        break;
      }
    }
    for (int i = 1; i <= n; ++i) {
      printf("%d", path[(x + i) % n] + 1);
      if (i == n)
        puts("");
      else
        putchar(' ');
    }
  }
  return 0;
}

詳細信息

Test #1:

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

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 1 2
1, 2, 4, 3, 
2 4 3 1

result:

wrong output format Expected integer, but "1," found