제출 #523791

#제출 시각아이디문제언어결과실행 시간메모리
523791fatemetmhrA Difficult(y) Choice (BOI21_books)C++17
0 / 100
4 ms5084 KiB
// Be name khoda // #include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long ll; const int maxn5 = 3e5 + 10; const int lg = 20; #define pb push_back #define se second #define fi first // // --- 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. // int n, k, s; ll A, have; ll a[maxn5]; int cnt = 0; inline int skimm(int i){ if(a[i] != -1) return a[i]; cnt++; if(cnt > s){ cout << 1 / 0 << endl; exit(0); } return skim(i); } inline bool check(int pre){ ll have = 0; if(a[ n - (k - 1 - pre)] == -1) a[ n - (k - 1 - pre)] = skimm( n - (k - 1 - pre)); for(int i = 1; i <= pre; i++) have += a[i]; for(int i = n - (k - 1 - pre); i <= n; i++) have += a[i]; return have >= A; } inline bool ok(int id){ return have + skimm(id) <= 2 * A; } inline int rebuild(){ ll have = 0; for(int i = 1; i <= k; i++){ a[i] = skimm(i); if(i < k) have += a[i]; } int lo = k, hi = n + 1; while(hi - lo > 1){ int mid = (lo + hi) >> 1; a[mid] = skimm(mid); if(have + a[mid] <= 2 * A) lo = mid; else hi = mid; } if(have + a[lo] >= A){ vector <int> ret; ret.clear(); for(int i = 1; i < k; i++) ret.pb(i); ret.pb(lo); answer(ret); } return lo; } void solve(int N, int K, long long AA, int S) { n = N; k = K; s = S; A = AA; memset(a, -1, sizeof a); cout << 1 / 0 << endl; n = rebuild(); for(int i = n - k + 1; i <= n; i++) a[i] = skimm(i); int lo = 0, hi = k; while(hi - lo > 1){ int mid = (lo + hi) >> 1; if(check(mid)) lo = mid; else hi = mid; } //cout << lo << endl; //cout << check(1) << endl; if(lo == 0){ have = 0; for(int i = n - k + 1; i <= n; i++) have += a[i]; if(have < A) impossible(); } if(lo == k - 1){ have = 0; for(int i = 1; i <= k; i++) have += a[i]; if(have > 2 * A) impossible(); } have = 0; for(int i = 1; i <= lo; i++) have += a[i]; for(int i = n - (k - 1 - lo) + 1; i <= n; i++) have += a[i]; int l = lo + 1, r = n - (k - 1 - lo) + 1; while(r - l > 1){ int mid = (l + r) >> 1; if(ok(mid)) l = mid; else r = mid; } vector <int> ret; ret.clear(); for(int i = 1; i <= lo; i++) ret.pb(i); ret.pb(l); for(int i = n - (k - 1 - lo) + 1; i <= n; i++) ret.pb(i); answer(ret); if (skimm(2) == 42) { impossible(); } else { answer({1, 3}); } }

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

books.cpp: In function 'int skimm(int)':
books.cpp:36:13: warning: division by zero [-Wdiv-by-zero]
   36 |   cout << 1 / 0 << endl;
      |           ~~^~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:91:12: warning: division by zero [-Wdiv-by-zero]
   91 |  cout << 1 / 0 << endl;
      |          ~~^~~
#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...