QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105936#5015. 树bashkortCompile Error//C++201.7kb2023-05-16 01:09:372023-05-16 01:10:33

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-16 01:10:33]
  • 评测
  • [2023-05-16 01:09:37]
  • 提交

answer

#include <bits/stdc++.h>
#include "tree.h"

using namespace std;

void solver(int n, int A, int B) {
    int root = 0 % n + 1;

    vector<int> dep(n + 1);
    vector<vector<int>> level(n + 1);

    for (int i = 1; i <= n; ++i) {
        if (i != root) {
            dep[i] = ask(root, {i});
        }
        level[dep[i]].push_back(i);
    }

    vector<int> fa(n + 1);
    vector dist(n + 1, vector<int>(n + 1));
    vector<bool> used(n + 1);

    used[1] = true;

    auto query = [&](int x, vector<int> a) {
        int ans = 0;
        assert(used[x]);
        for (int to : a) {
            assert(used[to]);
            ans += dist[x][to];
        }
        return ans;
    };

    mt19937 rnd(228);

    for (int l = 1; l <= n; ++l) {
        for (int x : level[l]) {
            vector<int> c = level[l - 1];

            while (size(c) > 1) {
                shuffle(c.begin(), c.end(), rnd);
                vector<int> q(c.begin(), c.begin() + c.size() / 2);
                int aim = ask(x, q);
                vector<int> nxt;
                for (int p : c) {
                    if (query(p, q) + size(q) == aim) {
                        nxt.push_back(p);
                    }
                }
                c = nxt;
            }

            fa[x] = c[0];
            adj[fa[x]].push_back(x);
            used[x] = true;

            for (int to = 1; to <= n; ++to) {
                if (used[to]) {
                    dist[to][x] = dist[x][to] = (x == to ? 0 : dist[fa[x]][to] + 1);
                }
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (i != root) {
            answer(i, fa[i]);
        }
    }
}

详细

implementer.cpp: In function ‘void regduj260135279::init()’:
implementer.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |                 scanf("%d",&n);
      |                 ~~~~~^~~~~~~~~
implementer.cpp:45:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |                         scanf("%d%d",&u,&v);
      |                         ~~~~~^~~~~~~~~~~~~~
answer.code: In function ‘void solver(int, int, int)’:
answer.code:55:13: error: ‘adj’ was not declared in this scope
   55 |             adj[fa[x]].push_back(x);
      |             ^~~