제출 #754054

#제출 시각아이디문제언어결과실행 시간메모리
754054keta_tsimakuridzeSum Zero (RMI20_sumzero)C++14
0 / 100
1079 ms14932 KiB
#include<bits/stdc++.h> #define f first #define s second #define int long long #define pii pair<int,int> #define Pii pair<int, pair<int,int>> using namespace std; const int N = 2e5 + 5, mod = 1e9 + 7; // ! int t, ans[N], a[N]; set<pair<int, pair<int,int> >> v[N]; vector<int> V[N], p; map<int,int> f; void dfs(int u) { p.push_back(u); for(int i = 0; i < V[u].size(); i++) dfs(V[u][i]); p.pop_back(); while(v[u].size()) { Pii x = *--v[u].end(); v[u].erase(x); if(p.size() >= (1 << x.f) && p[(int)p.size() - (1 << x.f)] <= x.s.s) ans[x.s.f] += 1 << x.f, v[p[(int)p.size() - (1 << x.f)]].insert({x.f - 1, x.s}); else if(x.f) v[u].insert({x.f - 1, x.s}); } // p.push_back(u); } main(){ int n, q; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } cin >> q; int mn = n + 1; for(int i = n; i >= 0; i--) { if(f[a[i]]) mn = min(mn, f[a[i]]); V[mn].push_back(i); f[a[i]] = i; } for(int i = 1; i <= q; i++) { int l, r; cin >> l >> r; --l; v[l].insert({3, {i, r}}); } dfs(n + 1); for(int i = 1; i <= q; i++) cout << ans[i] << " "; }

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

sumzero.cpp: In function 'void dfs(long long int)':
sumzero.cpp:15:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 0; i < V[u].size(); i++) dfs(V[u][i]);
      |                    ~~^~~~~~~~~~~~~
sumzero.cpp:20:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if(p.size() >= (1 << x.f) && p[(int)p.size() - (1 << x.f)] <= x.s.s) ans[x.s.f] += 1 << x.f, v[p[(int)p.size() - (1 << x.f)]].insert({x.f - 1, x.s});
      |            ~~~~~~~~~^~~~~~~~~~~~~
sumzero.cpp: At global scope:
sumzero.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...