제출 #895777

#제출 시각아이디문제언어결과실행 시간메모리
895777IsamIzbori (COCI22_izbori)C++17
0 / 110
3018 ms3164 KiB
#include<bits/stdc++.h> using namespace std; constexpr int sz = 200005; int tree[sz << 2]; inline void update(int l, int r, int node, int x, int val){ if(l > x || r < x) return; if(l == r){ tree[node] += val; return; } int mid = l + ((r - l) >> 1); update(l, mid, node << 1, x, val); update(mid + 1, r, node << 1 | 1, x, val); tree[node] = tree[node << 1] + tree[node << 1 | 1]; return; } int get_ans(int l, int r, int node, int L, int R){ if(l > R || r < L) return 0; if(l >= L && r <= R) return tree[node]; int mid = l + ((r - l) >> 1); return get_ans(l, mid, node << 1, L, R) + get_ans(mid + 1, r, node << 1 | 1, L, R); } signed main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int N; cin >> N; vector<int> A(N); for(register int i = 0; i < N; ++i){ cin >> A[i]; if(A[i] == 2) update(1, N, 1, i + 1, 1); } int ans(0); for(register int i = 0; i < N; ++i){ for(register int j = i; j < N; ++j){ int that = get_ans(1, N, 1, i + 1, j + 1); that = max(that, (j - i + 1) - that); ans += ((that << 1) > (j - i + 1)); } } cout << ans << '\n'; /* 2 2 1 2 3 2; 2; 1; 2; 3; 2 2; 2 2 1; 2 1 2; 2 2 1 2; 2 2 1 2 3; */ return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:32:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |  for(register int i = 0; i < N; ++i){
      |                   ^
Main.cpp:37:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |  for(register int i = 0; i < N; ++i){
      |                   ^
Main.cpp:38:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   38 |   for(register int j = i; j < N; ++j){
      |                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...