QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#798466#408. Dungeon 20x3b800001Compile Error//C++141.9kb2024-12-04 13:59:182024-12-04 13:59:19

Judging History

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

  • [2024-12-04 13:59:19]
  • 评测
  • [2024-12-04 13:59:18]
  • 提交

answer

#include "graph.h"
#include <vector>
#include <cmath>

int N = 1;
int fa[207], tofa[207], fato[207];
std::vector<std::pair<std::pair<int, int>, int>> E[207];

void dfs_tree(int u) {
  int d = NumberOfRoads();
  for (int i = 1; i <= d; ++i) {
    Move(i, 2);
    int c = Color();
    if (c == 1) {
      int v = ++N;
      fa[v] = u, tofa[v] = LastRoad(), fato[v] = i; 
      dfs_tree(v);
      Move(tofa[v], 3);
    } else if (c == 2) {
      if (i != tofa[u]) {
        E[u].push_back({{i, LastRoad()}, 0});
      }
      Move(LastRoad(), 2);
    } else {
      Move(LastRoad(), 3);
    }
  }
}

void dfs_calc(int u, int g) {
  int d = NumberOfRoads();
  for (int i = 1; i <= N; ++i) {
    if (fa[i] == u) {
      Move(fato[i], (u / int(std::pow(3, g))) % 3 + 1);
      dfs_calc(i, g);
      Move(tofa[i], (i / int(std::pow(3, g))) % 3 + 1);
    }
  }
  for (auto& [fb, v] : E[u]) {
    Move(fb.first, (u / int(std::pow(3, g))) % 3 + 1);
    int c = Color();
    v += (c - 1) * int(std::pow(3, g));
    Move(fb.second, c);
  }
}

int dis[207][207];

void Inspect(int R) {
  dfs_tree(1);
  dfs_calc(1, 0);
  dfs_calc(1, 1);
  dfs_calc(1, 2);
  dfs_calc(1, 3);
  dfs_calc(1, 4);
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      dis[i][j] = +0x3b9aca00;
    }
    dis[i][i] = 0;
  }
  for (int i = 2; i <= N; ++i) {
    dis[i][fa[i]] = dis[fa[i]][i] = 1;
    for (auto [fb, v] : E[i]) {
      dis[i][v] = dis[v][i] = 1;
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      for (int k = 1; k <= N; ++k) {
        dis[j][k] = std::min(dis[j][k], dis[j][i] + dis[i][k]);
      }
    }
  }
  for (int k = 1; k <= R; ++k) {
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j < i; ++j) {
        if (dis[i][j] == k) {
          ++ans;
        }
      }
    }
    Answer(k, ans);
  }
}

详细

implementer.cpp: In function ‘int main()’:
implementer.cpp:94:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   94 |                 scanf("%d", &(n_roads[i]));
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~
implementer.cpp:98:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   98 |                         scanf("%d", &(road[i][j]));
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~
implementer.cpp:105:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  105 |                 scanf("%d", &(expected_answer[i]));
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:1:10: fatal error: graph.h: No such file or directory
    1 | #include "graph.h"
      |          ^~~~~~~~~
compilation terminated.