제출 #1323541

#제출 시각아이디문제언어결과실행 시간메모리
1323541adscodingWorst Reporter 3 (JOI18_worst_reporter3)C++20
100 / 100
362 ms15176 KiB
#include <bits/stdc++.h> #define fi first #define se second #define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i) #define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i) #define FORLL(i, a, b) for (ll i = a, _b = b; i <= _b; ++i) #define FORDLL(i, a, b) for (ll i = a, _b = b; i >= _b; --i) #define all(x) x.begin(), x.end() #define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end()) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__) template<typename T> void __prine_one(const char *&s, const T &x) { while (*s == ' ') ++s; const char *p = s; int bal = 0; while (*s) { if (*s == '(') ++bal; else if (*s == ')') --bal; else if (*s == ',' && bal == 0) break; ++s; } cerr.write(p, s - p) << " = " << x; if (*s == ',') { cerr << " , "; ++s; } } template<typename... Args> void debug(const char *s, Args... args) { cerr << "[ "; int dummy[] = {0, (__prine_one(s, args), 0)...}; (void)dummy; cerr << " ]\n\n"; } template<class X, class Y> bool maximize(const X &a, const X &b) { if (a < b) { a = b; return true; } return false; } template<class X, class Y> bool minimize(const X &a, const X &b) { if (a > b) { a = b; return true; } return false; } // -------------------------------------------------------------------------------------------- const int maxn = 5e5 + 3; int n, q; ll D[maxn]; // -------------------------------------------------------------------------------------------- namespace sub2 { bool approve() { return true; } int state[maxn]; int process(int T, int L, int R) { FOR(i, 0, n) state[i] = -i; FOR(iT, 1, T) { ++state[0]; FOR(i, 1, n) { if (state[i - 1] - state[i] > D[i]) state[i] = state[i - 1] - 1; } } int res = 0; FOR(i, 0, n) res += state[i] >= L && state[i] <= R; return res; } void solve() { while (q--) { int T, L, R; cin >> T >> L >> R; if (L > R) return void(cout << 0 << '\n'); cout << process(T, L, R) << '\n'; } } } namespace AC { bool approve() { return true; } ll X[maxn], Y[maxn]; ll POS(ll i, ll T) { return -i + Y[i] * (T / X[i]); } void solve() { X[0] = 1; Y[0] = 1; FOR(i, 1, n) { ll cur = (D[i] - 1) / (Y[i - 1]) + 1; X[i] = X[i - 1] * cur; Y[i] = cur * Y[i - 1]; // dbg(i, X[i], Y[i]); } // exit(0); while (q--) { ll L, R, T; cin >> T >> L >> R; if (L > R) return void(cout << "0\n"); int l = 0, r = n; while (l <= r) { int mid = l + r >> 1; if (POS(mid, T) >= L) l = mid + 1; else r = mid - 1; } int bR = r; l = 0, r = n; while (l <= r) { int mid = l + r >> 1; if (POS(mid, T) <= R) r = mid - 1; else l = mid + 1; } int bL = l; cout << max(0, bR - bL + 1) << '\n'; } } } void solve() { cin >> n >> q; FOR(i, 1, n) cin >> D[i]; AC :: solve(); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define TASK "TEST" if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } solve(); return 0; }

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

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:201:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  201 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:202:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  202 |         freopen(TASK".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...