제출 #470101

#제출 시각아이디문제언어결과실행 시간메모리
470101Haruto810198A Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms200 KiB
#include <bits/stdc++.h> #include "books.h" #define ll long long #define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d)) #define vi vector<int> #define pb push_back 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. // const int MAX = 100010; ll arr[MAX]; ll sum[11]; // sum[i] : pref = i, suf = k - i vector<int> res; int query(int id){ if(arr[id] == 0) arr[id] = skim(id); return arr[id]; } void solve(int N, int K, ll A, int Q){ FOR(i, 1, K, 1){ query(i); query(N-i+1); } FOR(i, 0, K, 1){ // sum[i] FOR(j, 1, i, 1){ sum[i] += query(j); } for(int j = N; j > N - (K - i); j--){ sum[i] += query(j); } } if(sum[0] < A or sum[K] > 2*A){ impossible(); return; } FOR(i, 0, K, 1){ if(A <= sum[i] and sum[i] <= 2*A){ FOR(j, 1, i, 1){ res.pb(j); } for(int j = N; j > N - (K - i); j--){ res.pb(j); } answer(res); return; } } int sum_id; int L, R, mid; for(int i = K; i >= 0; i--){ if(sum[i] < A){ sum_id = i; L = sum_id - 1; R = L + (N - K); } } while(L < R){ mid = (L + R) / 2; query(mid); int new_sum = sum[sum_id] - arr[sum_id - 1] + arr[mid]; if(new_sum >= A){ R = mid; } else{ L = mid + 1; } } FOR(j, 1, sum_id - 1, 1){ res.pb(j); } for(int j = N; j > N - (K - sum_id); j--){ res.pb(j); } res.pb(L); answer(res); return; }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:78:18: warning: 'R' may be used uninitialized in this function [-Wmaybe-uninitialized]
   78 |         mid = (L + R) / 2;
      |               ~~~^~~~
books.cpp:6:41: warning: 'sum_id' may be used uninitialized in this function [-Wmaybe-uninitialized]
    6 | #define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
      |                                         ^~
books.cpp:66:9: note: 'sum_id' was declared here
   66 |     int sum_id;
      |         ^~~~~~
#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...