Submission #933782

#TimeUsernameProblemLanguageResultExecution timeMemory
933782berrA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms1112 KiB
#include"books.h" #include <bits/stdc++.h> using namespace std; vector<long long> vis; int flag=1, a; long long s(int a){ if(vis[a]!=-1) return vis[a]; else return vis[a] = skim(a+1); } void ans(int left, int right, int extra){ vector<int> a; for(int i=1; i<=left; i++) a.push_back(i); for(int i=vis.size(); i>vis.size()-right; i--) a.push_back(i); if(extra!=-1)a.push_back(extra); sort(a.begin(), a.end()); answer(a); } void get(int l, int r, long long tsum){ int k = l; long long sum=0; for(int i=0; i<l; i++) sum+=s(i); for(int i=vis.size()-1; i>vis.size()-r; i--) sum+=s(i); for(int j=17; j>=0; j--){ int tmp = k+(1<<j); if(tmp>=vis.size()||tmp>=vis.size()-r) continue; if(s(tmp)+sum <= 2*a) k= tmp; } flag = 0; if(k<vis.size()-r&&sum+s(k) <=2*a && sum+s(k) >=a) ans(l, r, k); return impossible(); } void solve(int N, int K, long long A, int S) { vis.resize(N+1, -1LL); a = A; long long sum=0; int l, r; for(int i=0; i<K; i++) sum+=(long long)s(i); for(int i=N-1; i>=N-K; i--) s(i); l=K; r=0; if(sum>2*A) return impossible(); else if(sum>=A) ans(l, r, -1); else{ for(int i=0; i<K&&flag; i++){ l--; r++; long long tsum=sum; sum-=s(K-1-i); sum+=s(N-i-1); if(sum>2*A) get(l-1, r-1, tsum); else if(sum>=A) ans(l, r, -1); } if(flag) impossible(); } }

Compilation message (stderr)

books.cpp: In function 'void ans(int, int, int)':
books.cpp:16:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=vis.size(); i>vis.size()-right; i--) a.push_back(i);
      |                           ~^~~~~~~~~~~~~~~~~
books.cpp: In function 'void get(int, int, long long int)':
books.cpp:26:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=vis.size()-1; i>vis.size()-r; i--) sum+=s(i);
      |                             ~^~~~~~~~~~~~~
books.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(tmp>=vis.size()||tmp>=vis.size()-r) continue;
      |            ~~~^~~~~~~~~~~~
books.cpp:30:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(tmp>=vis.size()||tmp>=vis.size()-r) continue;
      |                             ~~~^~~~~~~~~~~~~~
books.cpp:34:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if(k<vis.size()-r&&sum+s(k) <=2*a && sum+s(k) >=a) ans(l, r, k);
      |        ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...