Submission #799583

#TimeUsernameProblemLanguageResultExecution timeMemory
799583laurasofiaA Difficult(y) Choice (BOI21_books)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" #define vv vector<int> #define FOR(i, a, n) for (int i = a; i < n; i++) #define mkp make_pair #define INF 1000000003 using namespace std; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // void solve(int N, int K, long long A, int S) { // TODO implement this function vector<long long> v(N); int y=A/K; int idx; int l=1; int r=N; while (l+1<r){ int m=(l+r)>>1; int k=skim(m); if (k>y)r=m; else l=m; } vv v(K+1); long long sum=0; FOR(i,0,K){ if (l+i>N){ impossible(); return; } v[i]=skim(l+i); sum+=v[i]; } if (sum>=A && sum<=2*A){ vv ans; FOR(i,0,K)ans.push_back(l+i); answer(ans); return; } if (l+K<=N){ sum+=skim(l+K); sum-=v[0]; l++; if (sum>=A && sum<=2*A){ vv ans; FOR(i,0,K)ans.push_back(l+i); answer(ans); return; } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:35:8: error: conflicting declaration 'std::vector<int> v'
   35 |     vv v(K+1);
      |        ^
books.cpp:23:23: note: previous declaration as 'std::vector<long long int> v'
   23 |     vector<long long> v(N);
      |                       ^
books.cpp:25:9: warning: unused variable 'idx' [-Wunused-variable]
   25 |     int idx;
      |         ^~~