Submission #718257

# Submission time Handle Problem Language Result Execution time Memory
718257 2023-04-03T18:23:36 Z stevancv ICC (CEOI16_icc) C++14
100 / 100
128 ms 504 KB
#include <bits/stdc++.h>
#include "icc.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 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];
vector<int> G(vector<int> x, vector<int> y) {
    while (x.size() > 1) {
        vector<int> tmp[2];
        for (int i = 0; i < x.size(); i++) tmp[i & 1].push_back(x[i]);
        if (Query(tmp[0], y) == 1) x = tmp[0];
        else x = tmp[1];
    }
    return x;
}
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;
        for (int i = 0; ; i++) {
            for (int j = 0; j < sz; j++) {
                if ((1 << i) & j) a.push_back(v[j]);
                else b.push_back(v[j]);
            }
            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);
        a = G(a, b);
        b = G(b, a);
        int inda = a[0]; int indb = b[0];
        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();
    }
}

Compilation message

icc.cpp: In function 'std::vector<int> G(std::vector<int>, std::vector<int>)':
icc.cpp:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int i = 0; i < x.size(); i++) tmp[i & 1].push_back(x[i]);
      |                         ~~^~~~~~~~~~
icc.cpp: In lambda function:
icc.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 468 KB Ok! 96 queries used.
2 Correct 5 ms 468 KB Ok! 101 queries used.
# Verdict Execution time Memory Grader output
1 Correct 37 ms 468 KB Ok! 516 queries used.
2 Correct 38 ms 468 KB Ok! 667 queries used.
3 Correct 35 ms 468 KB Ok! 666 queries used.
# Verdict Execution time Memory Grader output
1 Correct 90 ms 496 KB Ok! 1393 queries used.
2 Correct 121 ms 504 KB Ok! 1626 queries used.
3 Correct 108 ms 488 KB Ok! 1488 queries used.
4 Correct 109 ms 500 KB Ok! 1493 queries used.
# Verdict Execution time Memory Grader output
1 Correct 97 ms 500 KB Ok! 1451 queries used.
2 Correct 125 ms 468 KB Ok! 1481 queries used.
3 Correct 107 ms 504 KB Ok! 1607 queries used.
4 Correct 94 ms 496 KB Ok! 1410 queries used.
# Verdict Execution time Memory Grader output
1 Correct 120 ms 504 KB Ok! 1639 queries used.
2 Correct 128 ms 468 KB Ok! 1580 queries used.
3 Correct 113 ms 500 KB Ok! 1624 queries used.
4 Correct 116 ms 504 KB Ok! 1606 queries used.
5 Correct 113 ms 504 KB Ok! 1460 queries used.
6 Correct 106 ms 468 KB Ok! 1538 queries used.
# Verdict Execution time Memory Grader output
1 Correct 104 ms 504 KB Ok! 1607 queries used.
2 Correct 103 ms 488 KB Ok! 1578 queries used.