Submission #531135

#TimeUsernameProblemLanguageResultExecution timeMemory
531135ColourAttilaCounting Mushrooms (IOI20_mushrooms)C++17
Compilation error
0 ms0 KiB
vector<int> knownA , knownB, ask; int cnt; int query1(vector<int> a) { int res = use_machine(a); if(res == 1) { knownB.push_back(a.back()); } else { knownA.push_back(a.back()); } return res; } int query2(vector<int> a, bool type) { int res = use_machine(a); //cout << "type: " << type << endl; if(((res & 2) == 2) == type) { knownB.push_back(a[1]); } else { knownA.push_back(a[1]); } if(((res & 1) == 1) == type) { knownB.push_back(a.back()); } else { knownA.push_back(a.back()); } return res; } int query3(vector<int> a, bool type) { int res = use_machine(a); if(type) { cnt += (a.size() - res) / 2; if(!(res % 2)) knownA.push_back(a.back()); else knownB.push_back(a.back()); } else { cnt += (res + 1) / 2; if(res % 2) knownA.push_back(a.back()); else knownB.push_back(a.back()); } return res; } int count_mushrooms(int n){ knownA.push_back(0); ask = {0, 1}; int curr = 1; // van legalabb 2 int res = query1(ask); if(res == 1) { ask[1] = 2; query1(ask); curr++; } int sq = sqrt(n); //gyöknyi ugyanolyan keresese while(knownA.size() < sq && knownB.size() < sq) { ask.clear(); bool type; if(knownA.size() > 1) { ask = {knownA[0], ++curr, knownA[1], ++curr}; type = 1; } else { ask = {knownB[0], ++curr, knownB[1], ++curr}; type = 0; } query2(ask, type); } // megoldas cnt = knownA.size(); while(curr < n) { ask.clear(); bool type; if(knownA.size() > knownB.size()) { type = 1; for(int i = 0; i < knownA.size(); i++) { ask.push_back(knownA[i]); ask.push_back(++curr); if(curr == n) break; } } else { type = 2; for(int i = 0; i < knownB.size(); i++) { ask.push_back(knownB[i]); ask.push_back(++curr); if(curr == n) break; } } query3(ask, type); } return cnt; }

Compilation message (stderr)

mushrooms.cpp:1:1: error: 'vector' does not name a type
    1 | vector<int> knownA , knownB, ask;
      | ^~~~~~
mushrooms.cpp:5:12: error: 'vector' was not declared in this scope
    5 | int query1(vector<int> a) {
      |            ^~~~~~
mushrooms.cpp:5:19: error: expected primary-expression before 'int'
    5 | int query1(vector<int> a) {
      |                   ^~~
mushrooms.cpp:18:12: error: 'vector' was not declared in this scope
   18 | int query2(vector<int> a, bool type) {
      |            ^~~~~~
mushrooms.cpp:18:19: error: expected primary-expression before 'int'
   18 | int query2(vector<int> a, bool type) {
      |                   ^~~
mushrooms.cpp:18:27: error: expected primary-expression before 'bool'
   18 | int query2(vector<int> a, bool type) {
      |                           ^~~~
mushrooms.cpp:18:36: error: expression list treated as compound expression in initializer [-fpermissive]
   18 | int query2(vector<int> a, bool type) {
      |                                    ^
mushrooms.cpp:39:12: error: 'vector' was not declared in this scope
   39 | int query3(vector<int> a, bool type) {
      |            ^~~~~~
mushrooms.cpp:39:19: error: expected primary-expression before 'int'
   39 | int query3(vector<int> a, bool type) {
      |                   ^~~
mushrooms.cpp:39:27: error: expected primary-expression before 'bool'
   39 | int query3(vector<int> a, bool type) {
      |                           ^~~~
mushrooms.cpp:39:36: error: expression list treated as compound expression in initializer [-fpermissive]
   39 | int query3(vector<int> a, bool type) {
      |                                    ^
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:58:5: error: 'knownA' was not declared in this scope
   58 |     knownA.push_back(0);
      |     ^~~~~~
mushrooms.cpp:59:5: error: 'ask' was not declared in this scope
   59 |     ask = {0, 1};
      |     ^~~
mushrooms.cpp:64:25: error: 'query1' cannot be used as a function
   64 |     int res = query1(ask);
      |                         ^
mushrooms.cpp:67:19: error: 'query1' cannot be used as a function
   67 |         query1(ask);
      |                   ^
mushrooms.cpp:71:14: error: 'sqrt' was not declared in this scope; did you mean 'sq'?
   71 |     int sq = sqrt(n);
      |              ^~~~
      |              sq
mushrooms.cpp:74:33: error: 'knownB' was not declared in this scope
   74 |     while(knownA.size() < sq && knownB.size() < sq) {
      |                                 ^~~~~~
mushrooms.cpp:87:25: error: 'query2' cannot be used as a function
   87 |         query2(ask, type);
      |                         ^
mushrooms.cpp:96:28: error: 'knownB' was not declared in this scope
   96 |         if(knownA.size() > knownB.size()) {
      |                            ^~~~~~
mushrooms.cpp:113:25: error: 'query3' cannot be used as a function
  113 |         query3(ask, type);
      |                         ^