이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
vector<int> vis;
int flag=1, a;
int 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, int tsum){
int k = l; int 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(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);
a = A;
int sum=0;
int l, r;
for(int i=0; i<K; i++) sum+=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++;
int 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();
}
}
컴파일 시 표준 에러 (stderr) 메시지
books.cpp: In function 'void ans(int, int, int)':
books.cpp:17:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for(int i=vis.size(); i>vis.size()-right; i--) a.push_back(i);
| ~^~~~~~~~~~~~~~~~~
books.cpp: In function 'void get(int, int, int)':
books.cpp:27:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=vis.size()-1; i>vis.size()-r; i--) sum+=s(i);
| ~^~~~~~~~~~~~~
books.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | if(tmp>=vis.size()||tmp>=vis.size()-r) continue;
| ~~~^~~~~~~~~~~~
books.cpp:31:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | if(tmp>=vis.size()||tmp>=vis.size()-r) continue;
| ~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |