Submission #717931

# Submission time Handle Problem Language Result Execution time Memory
717931 2023-04-02T21:09:53 Z stevancv ICC (CEOI16_icc) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 100 + 2;
const int inf = 1e9;
vector<int> svi[N];
int query(int n, int m, int a[], int b[]) {
    for (int i = 0; i < n; i++) cout << a[i] << sp;
    cout << en;
    for (int i = 0; i < m; i++) cout << b[i] << sp;
    cout << en;
    cout.flush();
    int x; cin >> x;
    return x;
}
void setRoad(int a, int b) {
    cout << "! " << a << sp << b << en;
    cout.flush();
}
int aaa[N], bbb[N];
int Query(vector<int> a, vector<int> b) {
    int A = a.size(); int B = b.size();
    for (int i = 0; i < A; i++) aaa[i] = a[i];
    for (int i = 0; i < B; i++) bbb[i] = b[i];
    return query(A, B, aaa, bbb);
}
int gazda[N];
void run(int n) {
    vector<int> v;
    for (int i = 1; i <= n; i++) {
        svi[i].push_back(i);
        gazda[i] = i;
    }
    auto Sredi = [&] (vector<int> v) {
        vector<int> ret;
        for (int i = 0; i < v.size(); i++) {
            for (int j : svi[v[i]]) ret.push_back(j);
        }
        return ret;
    };
    for (int zz = 0; zz < n - 1; zz++) {
        vector<int> v;
        for (int i = 1; i <= n; i++) {
            if (gazda[i] == i) v.push_back(i);
        }
        int sz = v.size();
        vector<int> a, b;
        while (1) {
            random_shuffle(v.begin(), v.end());
            for (int i = 0; i < sz / 2; i++) a.push_back(v[i]);
            for (int i = sz / 2; i < sz; i++) b.push_back(v[i]);
            auto aa = Sredi(a); auto bb = Sredi(b);
            if (Query(aa, bb) == 1) break;
            else {a.clear(); b.clear();}
        }
        a = Sredi(a); b = Sredi(b);
        int l = 0, r = a.size() - 2, inda = a.back();
        while (l <= r) {
            int mid = l + r >> 1;
            vector<int> tr;
            for (int i = 0; i <= mid; i++) tr.push_back(a[i]);
            if (Query(tr, b) == 1) {
                inda = a[mid];
                r = mid - 1;
            }
            else l = mid + 1;
        }
        l = 0, r = b.size() - 2;
        int indb = b.back();
        while (l <= r) {
            int mid = l + r >> 1;
            vector<int> tr;
            for (int i = 0; i <= mid; i++) tr.push_back(b[i]);
            if (Query({inda}, tr) == 1) {
                indb = b[mid];
                r = mid - 1;
            }
            else l = mid + 1;
        }
        setRoad(inda, indb);
        while (gazda[inda] != inda) inda = gazda[inda];
        while (gazda[indb] != indb) indb = gazda[indb];
        for (int i : svi[indb]) {
            svi[inda].push_back(i);
            gazda[i] = inda;
        }
        svi[indb].clear();
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    run(n);
    return 0;
}

Compilation message

icc.cpp: In lambda function:
icc.cpp:41:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:64:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |             int mid = l + r >> 1;
      |                       ~~^~~
icc.cpp:76:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   76 |             int mid = l + r >> 1;
      |                       ~~^~~
/usr/bin/ld: /tmp/cc9hyM3f.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccob3Iqg.o:icc.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc9hyM3f.o: in function `main':
grader.cpp:(.text.startup+0x17): undefined reference to `run'
collect2: error: ld returned 1 exit status