Submission #1161861

#TimeUsernameProblemLanguageResultExecution timeMemory
1161861zyq181Library (JOI18_library)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "library.h" using namespace std; #define int long long int N; vector<int> ask; vector<int> ask2; vector<int> ans; bool determined[1005]; int determinedcnt; int lastright = -1; int lastleft = -1; void side(int lo, int hi){ while(lo < hi){ int m = (lo + hi)/2; int sz = (m - lo + 1); fill(ask.begin(), ask.end(), 0); fill(ask2.begin(), ask2.end(), 0); int cnt = 0; for(int a=0; a<N; a++){ if(!determined[a]){ if(cnt < sz){ ask[a] = 1; cnt++; } else{ ask2[a] = 1; } } } int ret1 = Query(ask); int ret2 = Query(ask2); if(ret1 > ret2){ hi = m; } else{ lo = m + 1; } } int cntr = 0; for(int a=0; a<N; a++){ if(!determined[a]){ cntr++; } if(cntr == lo) { cntr = a + 1; break; } } if(lastright == N && lastleft == -1){ lastleft++; determined[cntr-1] = true; ans[lastleft] = cntr; } else if(lastright == N){ fill(ask.begin(), ask.end(), 0); ask[ans[lastleft] - 1] = 1; ask[cntr-1] = 1; ret = Query(ask); if(ret == 1){ lastleft++; ans[lasleft] = cntr; determined[cntr-1] = true; }else{ lastright--; ans[lastright] = cntr; determined[cntr-1] = true; } } else{ fill(ask.begin(), ask.end(), 0); ask[ans[lastright] - 1] = 1; ask[cntr-1] = 1; ret = Query(ask); if(ret == 1){ lastright--; ans[lastright] = cntr; determined[cntr-1] = true; }else{ lastleft++; ans[lastleft] = cntr; determined[cntr-1] = true; } } } void Solve(int N){ lastright = N; for(int a=0; a<N; a++){ ask.push_back(0); ask2.push_back(0); ans.push_back(0); } for(int a=0; a<N; a++){ side(1, N-a); } Answer(ans); }

Compilation message (stderr)

library.cpp: In function 'void side(long long int, long long int)':
library.cpp:34:26: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   34 |         int ret1 = Query(ask);
      |                          ^~~
In file included from library.cpp:2:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:35:26: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   35 |         int ret2 = Query(ask2);
      |                          ^~~~
In file included from library.cpp:2:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:62:9: error: 'ret' was not declared in this scope
   62 |         ret = Query(ask);
      |         ^~~
library.cpp:62:21: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   62 |         ret = Query(ask);
      |                     ^~~
In file included from library.cpp:2:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:65:17: error: 'lasleft' was not declared in this scope; did you mean 'lastleft'?
   65 |             ans[lasleft] = cntr;
      |                 ^~~~~~~
      |                 lastleft
library.cpp:77:9: error: 'ret' was not declared in this scope
   77 |         ret = Query(ask);
      |         ^~~
library.cpp:77:21: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   77 |         ret = Query(ask);
      |                     ^~~
In file included from library.cpp:2:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp: In function 'void Solve(long long int)':
library.cpp:101:12: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
  101 |     Answer(ans);
      |            ^~~
In file included from library.cpp:2:
library.h:3:37: note: in passing argument 1 of 'void Answer(const std::vector<int>&)'
    3 | void Answer(const std::vector<int>& res);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~