Submission #1107217

#TimeUsernameProblemLanguageResultExecution timeMemory
110721712345678Inspections (NOI23_inspections)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long struct interval { ll l, r, x; interval(ll l, ll r, ll x): l(l), r(r), x(x) {} bool operator<(const interval &o) const {return l<o.l;} }; const int nx=2e5+5; ll n, m, q, l, r, t, sf[nx], res[nx], cur, sm, idx; set<interval> s; vector<pair<ll, ll>> v, qrs; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>m>>q; s.insert(interval(1, n, -1e18)); for (int i=1; i<=m; i++) { cin>>l>>r; auto itr=prev(s.upper_bound(interval(l, 0, 0))); auto tmp=interval(*itr); s.erase(itr); if (itr->r>=r) { v.push_back({t-tmp.x+l-tmp.l, r-l+1}); if (tmp.l<l) s.insert(interval(tmp.l, l-1, tmp.x)); s.insert(interval(l, r, t)); if (r<tmp.r) s.insert(interval(r+1, tmp.r, tmp.x+r+1-tmp.l)); t+=r-l+1; //cout<<"after "<<i<<'\n'; //for (auto x:s) cout<<x.l<<' '<<x.r<<' '<<x.x<<'\n'; continue; } else { v.push_back({t-(tmp.x+l-tmp.l), tmp.r-l+1}); if (tmp.l<l) s.insert(interval(tmp.l, l-1, tmp.x)); } itr=s.lower_bound(interval(l, 0, 0)); while (itr!=s.end()&&itr->l<=r) { if (itr->r<=r) { v.push_back({t+itr->l-l-itr->x, itr->r-itr->l+1}); itr=s.erase(itr); } else { v.push_back({t+itr->l-l-itr->x, r-itr->l+1}); if (r<idx->r) s.insert(interval(r+1, itr->r, itr->x+r-itr->l+1)); s.erase(itr); break; } } s.insert(interval(l, r, t)); t+=r-l+1; //cout<<"after "<<i<<'\n'; //for (auto x:s) cout<<x.l<<' '<<x.r<<' '<<x.x<<'\n'; } //for (auto x:v) cout<<x.first<<' '<<x.second<<'\n'; sort(v.begin(), v.end()); for (auto x:v) if (x.first<1e18) sm+=x.second; for (int i=1; i<=q; i++) cin>>sf[i], qrs.push_back({sf[i], i}); sort(qrs.begin(), qrs.end()); for (int i=0; i<q; i++) { while (idx<v.size()&&v[idx].first<=qrs[i].first) sm-=v[idx].second, idx++; res[qrs[i].second]=sm; } for (int i=1; i<=q; i++) cout<<res[i]<<' '; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:58:26: error: base operand of '->' is not a pointer
   58 |                 if (r<idx->r) s.insert(interval(r+1, itr->r, itr->x+r-itr->l+1));
      |                          ^~
Main.cpp:75:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         while (idx<v.size()&&v[idx].first<=qrs[i].first) sm-=v[idx].second, idx++;
      |                ~~~^~~~~~~~~