제출 #1206434

#제출 시각아이디문제언어결과실행 시간메모리
1206434phungmanager0Election (BOI18_election)C++20
0 / 100
1 ms576 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++) #define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--) #define REP(i, n) for (int i = 0, _n = (n); i < _n; i++) #define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++) #define ALL(v) (v).begin(), (v).end() #define IS_INF(x) (std::isinf(x)) #define IS_NAN(x) (std::isnan(x)) #define fi first #define se second #define int long long #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define div ___div #define prev ___prev #define next ___next #define left ___leftc #define right ___right #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define __Im_sobad__ main() #define __builtin_popcount __builtin_popcountll using namespace std; /* Phung Duc Minh will win hsgtp 2025 Phung Duc Minh will become top 1 ams Phung Duc Minh will be winner of IOI 2028 I love you so much but you can see(8E) !!!! ... Make 8E GRATE AGAIN!!! */ /* Nhận xét: */ const int MAXN = 5e5 + 5; const int INF = 1e18; int n, q, a[MAXN], ans[MAXN]; string s; struct Node { int sum, pre, suf; } t[4 * MAXN]; Node operator+(const Node& a, const Node& b) { Node res; res.sum = a.sum + b.sum; res.pre = max({a.pre, a.sum + b.pre}); res.suf = max({b.suf, b.sum + a.suf}); return res; } void build(int idx, int l, int r) { if(l == r) return void(t[idx] = {a[l], a[l], a[l]}); int mid = (l + r) >> 1; build(idx * 2, l, mid); build(idx * 2 + 1, mid + 1, r); t[idx] = t[idx * 2] + t[idx * 2 + 1]; } Node get(int idx, int l, int r, int u, int v) { if(r < u || v < l) return {0, -INF, -INF}; if(u <= l && r <= v) return t[idx]; int mid = (l + r) >> 1; Node q1 = get(idx * 2, l, mid, u, v); Node q2 = get(idx * 2 + 1, mid + 1, r, u, v); return q1 + q2; } void solve() { cin >> n >> s; REP(i, n) { if(s[i] == 'C') a[i + 1] = -1; else a[i + 1] = 1; } build(1, 1, n); cin >> q; while(q--) { int l, r; cin >> l >> r; Node res = get(1, 1, n, l, r); cout << max(res.suf, res.pre) << "\n"; } } __Im_sobad__{ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); cerr << "Time elapsed: " << TIME << " s.\n"; return 0; } // Author: Phung Duc Minh // Look at my code, my code is so amazing and legit // Try to be better!

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

election.cpp:20:22: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | #define __Im_sobad__ main()
      |                      ^~~~
election.cpp:76:1: note: in expansion of macro '__Im_sobad__'
   76 | __Im_sobad__{
      | ^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...