Submission #717879

#TimeUsernameProblemLanguageResultExecution timeMemory
717879stevancvICC (CEOI16_icc)C++14
Compilation error
0 ms0 KiB
#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]; void Nadji(vector<int> a, vector<int> b) { cout << "THU" << endl; int l = 0, r = a.size() - 2, xx = 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(mid + 1, b.size(), tr, b) == 1) { xx = a[mid]; r = mid - 1; } else l = mid + 1; } l = 0, r = b.size() - 2; int yy = 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(mid + 1, 1, tr, {xx}) == 1) { yy = b[mid]; r = mid - 1; } else l = mid + 1; } setRoad(xx, yy); } int gazda[N]; void run(int n) { vector<int> v; for (int i = 1; i <= n; i++) { svi[i].push_back(i); gazda[i] = 1; } 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] == 1) 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.size(), bb.size(), aa, bb) == 1) break; else {a.clear(); b.clear();} } int l = 0, r = a.size() - 2, inda = a.back(); auto bb = Sredi(b); while (l <= r) { int mid = l + r >> 1; vector<int> tr; for (int i = 0; i <= mid; i++) tr.push_back(a[i]); auto ttr = Sredi(tr); if (query(ttr.size(), bb.size(), ttr, bb) == 1) { inda = a[mid]; r = mid - 1; } else l = mid + 1; } l = 0, r = b.size() - 2; int indb = b.back(); auto aa = Sredi({inda}); while (l <= r) { int mid = l + r >> 1; vector<int> tr; for (int i = 0; i <= mid; i++) tr.push_back(b[i]); auto ttr = Sredi(tr); if (query(aa.size(), ttr.size(), aa, tr) == 1) { indb = b[mid]; r = mid - 1; } else l = mid + 1; } Nadji(svi[inda], svi[indb]); if (inda > indb) swap(inda, indb); for (int i : svi[indb]) { svi[inda].push_back(i); gazda[i] = 0; } svi[indb].clear(); } }

Compilation message (stderr)

icc.cpp: In function 'void Nadji(std::vector<int>, std::vector<int>)':
icc.cpp:17:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |         int mid = l + r >> 1;
      |                   ~~^~~
icc.cpp:20:38: error: cannot convert 'std::vector<int>' to 'int*'
   20 |         if (query(mid + 1, b.size(), tr, b) == 1) {
      |                                      ^~
      |                                      |
      |                                      std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:29:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   29 |         int mid = l + r >> 1;
      |                   ~~^~~
icc.cpp:32:31: error: cannot convert 'std::vector<int>' to 'int*'
   32 |         if (query(mid + 1, 1, tr, {xx}) == 1) {
      |                               ^~
      |                               |
      |                               std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp: In lambda function:
icc.cpp:49:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:66:45: error: cannot convert 'std::vector<int>' to 'int*'
   66 |             if (query(aa.size(), bb.size(), aa, bb) == 1) break;
      |                                             ^~
      |                                             |
      |                                             std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:72:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   72 |             int mid = l + r >> 1;
      |                       ~~^~~
icc.cpp:76:46: error: cannot convert 'std::vector<int>' to 'int*'
   76 |             if (query(ttr.size(), bb.size(), ttr, bb) == 1) {
      |                                              ^~~
      |                                              |
      |                                              std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:86:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   86 |             int mid = l + r >> 1;
      |                       ~~^~~
icc.cpp:90:46: error: cannot convert 'std::vector<int>' to 'int*'
   90 |             if (query(aa.size(), ttr.size(), aa, tr) == 1) {
      |                                              ^~
      |                                              |
      |                                              std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^