제출 #753335

#제출 시각아이디문제언어결과실행 시간메모리
753335keta_tsimakuridzeSum Zero (RMI20_sumzero)C++14
61 / 100
526 ms43352 KiB
#include<bits/stdc++.h> #define f first #define s second //#define int long long #define pii pair<int,int> using namespace std; const int N = 4e5 + 5, mod = 1e9 + 7; // ! int t, R[N][20], a[N]; map<int,int> f; main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); int n; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } int mn = n + 1; for(int j = 0; j <= 19; j++) R[n + 1][j] = n + 1; for(int i = n; i >= 0; i--) { if(f[a[i]]) mn = min(mn, f[a[i]]); f[a[i]] = i; R[i][0] = mn; for(int j = 0 + 1; j < 20; j++) R[i][j] = R[R[i][j - 1]][j - 1]; } int q; cin >> q; while(q--) { int l, r, ans = 0; cin >> l >> r; --l; for(int j = 19; j >= 0; j--) { if(R[l][j] <= r) ans += (1 << j), l = R[l][j]; } cout << ans << "\n"; } }

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

sumzero.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...