QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371465#905. 三元环枚举IsrothyCompile Error//C++231.2kb2024-03-30 12:49:532024-03-30 12:49:54

Judging History

This is the latest submission verdict.

  • [2024-03-30 12:49:54]
  • Judged
  • [2024-03-30 12:49:53]
  • Submitted

answer

#include <cstdio>
#include <vector>
#include <span>
auto three_membered_rings(std::span<std::vector<int>> adj) {
    auto n = adj.size() - 1;
    std::vector<size_t> rank(n + 1);
    std::vector<int> vis_time(n + 1);
    std::vector<std::vector<int>> f(n + 1);
    for (int u = 1; u <= n; ++u) {
        rank[u] = (int64_t) adj[u].size() * (n + 1) + u;
    }
    for (int u = 1; u <= n; ++u) {
        for (auto v: adj[u]) {
            if (rank[u] < rank[v]) {
                f[u].push_back(v);
            }
        }
    }
    int res = 0;
    for (int u = 1; u <= n; ++u) {
        for (auto v: f[u]) {
            vis_time[v] = u;
        }
        for (auto v: f[u]) {
            for (auto w: f[v]) {
                if (vis_time[w] == u) {
                    ++res;
                }
            }
        }
    }
    return res;
}
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    std::vector<std::vector<int>> adj(n + 1);
    for (int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u;
        --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    printf("%d\n", three_membered_rings(adj));

    return 0;
}

详细

answer.code: In function ‘auto three_membered_rings(std::span<std::vector<int> >)’:
answer.code:10:20: error: ‘int64_t’ was not declared in this scope
   10 |         rank[u] = (int64_t) adj[u].size() * (n + 1) + u;
      |                    ^~~~~~~
answer.code:4:1: note: ‘int64_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    3 | #include <span>
  +++ |+#include <cstdint>
    4 | auto three_membered_rings(std::span<std::vector<int>> adj) {
answer.code: In function ‘int main()’:
answer.code:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
answer.code:40:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |         scanf("%d%d", &u, &v);
      |         ~~~~~^~~~~~~~~~~~~~~~