Submission #975252

# Submission time Handle Problem Language Result Execution time Memory
975252 2024-05-04T15:48:31 Z Circling Prize (CEOI22_prize) C++17
Compilation error
0 ms 0 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int n, k, q, t, p[20][500001], depth[500001], w[20][500001], root, a, b, ans;
pair<int, int> questions[t];
vector<int> chosen;
vector<vector<int>> children;


int main(){
    //cin.tie(0);
    //ios_base::sync_with_stdio(0);
    cin >> n >> k >> q >> t;
    children.resize(n + 1);
    for (int i = 1; i <= n; i++) cin >> p[0][0];
    for (int i = 1; i <= n; i++){
        cin >> p[0][i];
        if (p[0][i] != -1) children[p[0][i]].push_back(i);
        else root = i;
    }
    chosen = {root};
    depth[root] = 0;
    for (int i = 0; chosen.size() < k; i++){
        for (int c: children[chosen[i]]){
            chosen.push_back(c);
            depth[c] = depth[chosen[i]] + 1;
        }
    }
    chosen.resize(k);
    for (int c: chosen) cout << c << ' ';
    cout << endl;
    cout.flush();
    for (int c: chosen) if (c != root) cout << "? " << p[0][c] << ' ' << c << endl;
    cout << '!' << endl;
    cout.flush();
    for (int c: chosen) if (c != root) cin >> w[0][c] >> w[0][c] >> w[0][c] >> w[0][c];
    w[0][root] = 0;
    for (int i = 1; i < 20; i++){
        for (int j: chosen){
            p[i][j] = p[i - 1][p[i - 1][j]];
            w[i][j] = w[i - 1][j] + w[i - 1][p[i - 1][j]];
        }
    }
    for (int i = 0; i < t; i++) cin >> questions[i].first >> questions[i].second;
    for (int i = 0; i < t; i++){
        a = questions[i].first;
        b = questions[i].second;
        ans = 0;
        if (depth[a] < depth[b]) swap(a, b);
        for (int i = 0; i < 20; i++){
            if (((depth[a] - depth[b]) >> i) % 2 == 1){
                ans += w[i][a];
                a = p[i][a];
            }
        }
        for (int i = 19; i > -1; i--){
            if (p[i][a] != p[i][b]){
                ans += w[i][a] + w[i][b];
                a = p[i][a];
                b = p[i][b];
            }
        }
        if (a != b) ans += w[0][a] + w[0][b];
        cout << ans << ' ' << ans << endl;
    }
    cout.flush();
}

Compilation message

Main.cpp:26:27: error: array bound is not an integer constant before ']' token
   26 | pair<int, int> questions[t];
      |                           ^
Main.cpp: In function 'int main()':
Main.cpp:44:35: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     for (int i = 0; chosen.size() < k; i++){
      |                     ~~~~~~~~~~~~~~^~~
Main.cpp:65:40: error: 'questions' was not declared in this scope
   65 |     for (int i = 0; i < t; i++) cin >> questions[i].first >> questions[i].second;
      |                                        ^~~~~~~~~
Main.cpp:67:13: error: 'questions' was not declared in this scope
   67 |         a = questions[i].first;
      |             ^~~~~~~~~