제출 #933803

#제출 시각아이디문제언어결과실행 시간메모리
933803berrA 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()-1; i>=vis.size()-right; i--) a.push_back(i); if(extra!=-1)a.push_back(extra+1); sort(a.begin(), a.end()); answer(a); } int get(int l, int r){ int k = l-1; long long sum=0; for(int i=0; i<l; i++) sum+=s(i); for(int i=vis.size()-2; i>vis.size()-r-1; i--) sum+=s(i); for(int j=17; j>=0; j--){ int tmp = k+(1<<j); if(tmp>=vis.size()-r-1) continue; if(s(tmp)+sum <a) k= tmp; } k++; if(k<vis.size()-1-r&&sum+s(k) <=2*a && sum+s(k) >=a){ flag = 0; ans(l, r, k); } return k; } void solve(int N, int K, long long A, int S) { vis.resize(N+1, -1LL); a = A; int v=get(K-1, 0); if(flag){ for(int i=0; i<K; i++){ s(i); } for(int i=v-1; i>=v-K; i--){ s(i); } for(int i=0; i<=K&&flag; i++){ long long sum=0; for(int l=0; l<i; l++) sum+=s(l); for(int l=v-1; l>=v-(K-i); l--) sum+=s(l); if(sum>=A&&sum<=2*A){ vector<int> a; for(int l=0; l<i; l++) a.push_back(l+1); for(int l=v-K+i; l<=v-1; l++) a.push_back(l+1); flag = 0; answer(a); } } } if(flag) impossible(); }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'void ans(int, int, int)':
books.cpp:17:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=vis.size()-1; i>=vis.size()-right; i--) a.push_back(i);
      |                             ~^~~~~~~~~~~~~~~~~~
books.cpp: In function 'int get(int, int)':
books.cpp:27:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=vis.size()-2; i>vis.size()-r-1; i--) sum+=s(i);
      |                             ~^~~~~~~~~~~~~~~
books.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         if(tmp>=vis.size()-r-1) continue;
      |            ~~~^~~~~~~~~~~~~~~~
books.cpp:35:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if(k<vis.size()-1-r&&sum+s(k) <=2*a && sum+s(k) >=a){
      |        ~^~~~~~~~~~~~~~~
#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...