제출 #926725

#제출 시각아이디문제언어결과실행 시간메모리
926725TimDeeSum Zero (RMI20_sumzero)C++17
61 / 100
934 ms28276 KiB
// Esti <3 //\ šťastia pre nás :) // you're already the best // _ // ^ ^ // // >(O_O)<___// // \ __ __ \ // \\ \\ \\\\ #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3","unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("O3") #pragma GCC target("popcnt") using ll = long long; #define int long long #define forn(i,n) for(int i=0; i<(n); ++i) #define pb push_back #define pi pair<int,int> #define f first #define s second #define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i]; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll inf = 1e18; const ll mod = 998244353; // \ \ :smiling_face_with_3_hearts: :smiling_face_with_3_hearts: :smiling_face_with_3_hearts: //vidime sa veľmi skoro, moje slnko //[] {} //кто андрей столетний - того на вилы const int N=4e5+5; const int K=600; int par[N]; int go[N]; void solve() { int n; cin>>n; vii(a,n); map<int,int> m; int s=0; m[0]=n; forn(i,n+1) par[i]=n+1; for(int i=n-1; i>=0; --i) { s+=a[i]; if (m.count(s)) par[i]=m[s]; m[s]=i; } int mn=n+1; for(int i=n-1; i>=0; --i) { if (par[i]>-1) mn=min(mn,par[i]); par[i]=mn; } for(int i=0; i<n; ++i) { int u=i; for(int j=0; j<K && u<=n; ++j) { u=par[u]; } go[i]=u; } int q; cin>>q; forn(it,q) { int l,r; cin>>l>>r; int u=l-1; int ans=0; while (go[u] <= r) { ans+=K; u=go[u]; } while (par[u] <= r) { ++ans; u = par[u]; } cout<<ans<<'\n'; } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while (t--) solve(); return 0; }

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

sumzero.cpp:3:1: warning: multi-line comment [-Wcomment]
    3 | //\
      | ^
sumzero.cpp:9:1: warning: multi-line comment [-Wcomment]
    9 | //   \ __ __  \
      | ^
sumzero.cpp:36:1: warning: multi-line comment [-Wcomment]
   36 | // \
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...