Submission #1230278

#TimeUsernameProblemLanguageResultExecution timeMemory
1230278ByeWorldSum Zero (RMI20_sumzero)C++20
22 / 100
1095 ms2848 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define int long long #define ll long long #define se second #define fi first #define pb push_back #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) using namespace std; typedef pair<int,int> pii; typedef pair<pii,pii> ipii; const int MAXN = 4e5+10; const int SQRT = 450; const int INF = 2e18; const int MOD = 998244353; const int LOG = 30; int sum(int a, int b){ return (a+MOD+b)%MOD; } void chsum(int &a, int b){ a = (a+MOD+b)%MOD; } int mul(int a, int b){ return (a*b)%MOD; } void chmul(int &a, int b){ a = (a*b)%MOD; } void chmn(auto &a, auto b){ a = min(a, b); } void chmx(auto &a, auto b){ a = max(a, b); } int n, a[MAXN], pr[MAXN], q, dp[MAXN]; unordered_map<int,int> ma; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; for(int i=1; i<=n; i++){ cin>>a[i]; pr[i] = pr[i-1]+a[i]; } cin>>q; while(q--){ int tot = 0; ma.clear(); int x, y; cin>>x>>y; ma[pr[x-1]] = x; for(int i=x; i<=y; i++){ dp[i] = dp[i-1]; if(ma[ pr[i] ] == 0){ ma[ pr[i] ] = i; continue; } tot++; ma.clear(); ma[ pr[i] ] = i; } cout << tot << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...