Submission #754893

# Submission time Handle Problem Language Result Execution time Memory
754893 2023-06-08T20:46:02 Z MilosMilutinovic ICC (CEOI16_icc) C++14
Compilation error
0 ms 0 KB
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 101;
int n, fa[N];
int gfa(int x) { return fa[x] == x ? x : fa[x] = gfa(fa[x]); }
void add(vector<int>& v, int comp) {
    for (int i = 1; i <= n; i++)
        if (gfa(i) == gfa(comp))
            v.push_back(i);
}
void run(int n) {
    ::n = n;
    for (int i = 1; i <= n; i++) fa[i] = i;
    for (int iter = 1; iter <= n - 1; iter++) {
        vector<int> v;
        for (int i = 1; i <= n; i++)
            if (gfa(i) == i)
                v.push_back(i);
        int sz = (int) v.size(), lg = 0;
        while ((1 << lg) < sz) lg++;
        int xr = 0;
        for (int b = 0; b < lg; b++) {
            vector<int> l, r;
            for (int i = 0; i < sz; i++) {
                if (i >> b & 1) {
                    add(l, v[i]);
                } else {
                    add(r, v[i]);
                }
            }
            if (query(l, r))
                xr ^= (1 << b);
        }
        int f = 0;
        for (int b = 0; b < lg; b++)
            if (xr >> b & 1)
                f = b;
        int a = 0, b = 0;
        for (int i = 0; i < lg; i++) {
            if (xr >> i & 1) {
                vector<int> l, r;
                for (int j = 0; j < sz; j++) {
                    if (j >> f & 1) {
                        add(l, v[j]);
                    } else {
                        add(r, v[j]);
                    }
                }
                if (query(l, r))
                    a += (1 << i);
                else
                    b += (1 << i);
            } else {
                vector<int> l, r;
                for (int j = 0; j < sz; j++) {
                    if (j >> i & 1) continue;
                    if (j >> f & 1)
                        add(l, v[j]);
                    else
                        add(r, v[j]);
                }
                if (!query(l, r))
                    a += (1 << i), b += (1 << i);
            }
        }
        vector<int> l, r;
        for (int i = 1; i <= n; i++) {
            if (gfa(i) == v[a])
                l.push_back(i);
            if (gfa(i) == v[b])
                r.push_back(i);
        }
        int p = -1, q = -1;
        for (int x : l)
            for (int y : r)
                if (query({x}, {y}))
                    p = x, q = y;
        assert(p != -1);
        setRoad(p, q);
        fa[gfa(p)] = gfa(q);
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:32:23: error: cannot convert 'std::vector<int>' to 'int'
   32 |             if (query(l, r))
      |                       ^
      |                       |
      |                       std::vector<int>
In file included from icc.cpp:1:
icc.h:10:15: note:   initializing argument 1 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |           ~~~~^
icc.cpp:50:27: error: cannot convert 'std::vector<int>' to 'int'
   50 |                 if (query(l, r))
      |                           ^
      |                           |
      |                           std::vector<int>
In file included from icc.cpp:1:
icc.h:10:15: note:   initializing argument 1 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |           ~~~~^
icc.cpp:63:28: error: cannot convert 'std::vector<int>' to 'int'
   63 |                 if (!query(l, r))
      |                            ^
      |                            |
      |                            std::vector<int>
In file included from icc.cpp:1:
icc.h:10:15: note:   initializing argument 1 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |           ~~~~^
icc.cpp:77:35: error: too few arguments to function 'int query(int, int, int*, int*)'
   77 |                 if (query({x}, {y}))
      |                                   ^
In file included from icc.cpp:1:
icc.h:10:5: note: declared here
   10 | int query(int a, int b, int *A, int *B);
      |     ^~~~~