Submission #1244271

#TimeUsernameProblemLanguageResultExecution timeMemory
1244271minhpkLibrary (JOI18_library)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "library.h" #define int long long using namespace std; int n; vector <int> res; int del[1000005]; int ask(vector<int> q){ vector <int> q1(n); for (auto p:q){ q1[p-1]=1; } Query(q1); } void Solve(int N){ if (N==1){ vector <int> pre; pre.push_back(1); Answer(pre); return; } n=N; int a=N; int sta; for (int i=1;i<=a;i++){ vector <int> pre; for (int j=1;j<=a;j++){ if (j==i){ continue; } pre.push_back(j); } int val=ask(pre); if (val==1){ sta=i; break; } } int last=sta; del[sta]=1; for (int i=2;i<=a;i++){ vector <int> pre; for (int j=1;j<=a;j++){ if (del[j]){ continue; } pre.push_back(j); } int l=0; int r=pre.size()-1; int pos=0; while (l<=r){ int mid=(l+r)/2; vector <int> pre1(pre.begin(),pre.begin()+mid+1); int val=ask(pre1); pre1.push_back(last); int val1=ask(pre1); if (val==val1){ pos=mid; r=mid-1; }else{ l=mid+1; } } int x=pre[pos]; res.push_back(x); del[x]=1; last=x; } Answer(res); }

Compilation message (stderr)

library.cpp: In function 'long long int ask(std::vector<long long int>)':
library.cpp:13:11: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   13 |     Query(q1);
      |           ^~
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:14:1: warning: no return statement in function returning non-void [-Wreturn-type]
   14 | }
      | ^
library.cpp: In function 'void Solve(long long int)':
library.cpp:20:16: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   20 |         Answer(pre);
      |                ^~~
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);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~
library.cpp:72:12: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   72 |     Answer(res);
      |            ^~~
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);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~