Submission #1159397

#TimeUsernameProblemLanguageResultExecution timeMemory
1159397bilalcoSum Zero (RMI20_sumzero)C++20
0 / 100
458 ms504 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") using ll = long long; template<typename... T> void see(T&... args) { ((cin >> args), ...);} #define seea(a , x , y) for(int i = x; i < y; i++){cin >> a[i];} #define sees(s , n) for(int i = 0;i < n; i++){int x; cin >> x; s.insert(x);} #define seev(v , n) for(int i = 0;i < n; i++){int x; cin >> x; v.push_back(x);} #define ub(a, x) upper_bound(all(a), x) #define lb(a, x) lower_bound(all(a), x) #define rall(x) x.rbegin(), x.rend() #define all(x) x.begin(), x.end() #define pii pair<int , int> #define sz(x) (int)x.size() #define pq priority_queue #define vec vector #define arr array const ll inf = 1e18; const int N = 2e5 + 5; const short lg = 20; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } void solve() { // Code here int n; see(n); vec<int> a; seev(a , n); vec<int> pf(n + 1 , 0); for (int i = 0; i < n; i++) pf[i + 1] = pf[i] + a[i]; int q; see(q); while(q--){ int l , r; see(l , r); int cnt = 0; for (int i = l; i <= r; i++){ for (int j = i; j <= r; j++){ if (pf[j] - pf[i - 1] == 0){ cnt++; i = j; } } } cout << cnt << "\n"; } return; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); // setIO(""); solve(); }

Compilation message (stderr)

sumzero.cpp: In function 'void setIO(std::string)':
sumzero.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sumzero.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...