제출 #447016

#제출 시각아이디문제언어결과실행 시간메모리
447016hhhhauraA Difficult(y) Choice (BOI21_books)C++14
100 / 100
1 ms328 KiB
#include <bits/stdc++.h> #include "books.h" #define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i --) #define ceil(a, b) ((a + b - 1) / (b)) #define all(x) x.begin(), x.end() #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define lld long double #define ll long long int #define pii pair<int, int> #define random mt19938 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); } #else #define print(...) 0 #define vprint(...) 0 #endif // // --- 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) { ll ans = 0, L = 0, R = N + 1, val; vector<ll> p(K + 1, 0); rep(i, 1, K) { p[i] = skim(i); ans += p[i]; } while(R - L > 1) { ll mid = (L + R) / 2, cur; if(cur = skim(mid), cur >= A) { R = mid, val = cur; } else L = mid; } if(ans <= 2*A && ans >= A) { vector<int> a; rep(i, 1, K) a.push_back(i); answer(a); return; } else if(ans > 2 * A) { impossible(); return; } else if(R <= N && val + ans - p[K] <= 2 * A) { vector<int> a; rep(i, 1, K - 1) a.push_back(i); a.push_back(R); answer(a); return; } else { int cur = K, pre = R; rep(i, 1, K) { ans -= p[cur--]; ans += skim(--pre); if(ans >= A) { vector<int> a; rep(j, 1, cur) a.push_back(j); rep(j, pre, R - 1) a.push_back(j); answer(a); return; } } } impossible(); return; }

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

books.cpp:7: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    7 | #pragma loop-opt(on)
      | 
books.cpp:27:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   27 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
books.cpp:27:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   27 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:68:24: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   68 |  else if(R <= N && val + ans - p[K] <= 2 * 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...