Submission #1143790

#TimeUsernameProblemLanguageResultExecution timeMemory
1143790mattsohPilot (NOI19_pilot)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second typedef long long ll; const ll maxn = 1e5+10; pair<ll,ll> h[maxn]; vector<pair<ll,ll>> ranges; pair<ll,ll> p[maxn]; void rem(ll idx){ ll l = 0, r = ranges.size()-1; ll m; while (true){ m = (l+r)/2; if (ranges[m].fi <= idx && idx <= ranges[m].se) break; if (m<idx){ r = m; } else l = m; } pair<ll,ll> range = ranges[m]; if (range.fi == idx){ ranges[m].fi = idx+1; } else if (range.se == idx){ ranges[m].se = idx-1; } else{ ranges.insert(ranges.begin()+m+1,{idx+1,ranges[m].se}); ranges[m].se = idx; } } signed main(){ ll n,q;cin>>n>>q; for (ll i = 0;i<n;i++){ ll hgt;cin>>hgt; h[i] = {hgt,i}; } ranges.push_back({0,n}); sort(h,h+n); reverse(h,h+n); // for (ll i = 0;i<n;i++){ // cout<<h[i].fi<<h[i].se<<endl; // } ll maxh = n, curr = 0; for (ll i = 0;i<q;i++){ ll pl;cin>>pl; p[i] = {pl,i}; } sort(p,p+q); reverse(p,p+q); for (ll i = 0;i<q;i++){ ll plane = p[i].fi, ord = p[i].se; while (h[curr].fi > plane){ // cout<<"removing"<<h[curr].fi<<h[curr].se<<endl; rem(h[curr].se); curr++; } ll total = 0; for (auto range:ranges){ // cout<<"range"<<range.fi<<' '<<range.se<<endl; ll diff = range.se - range.fi; total += diff*(diff+1)/2; } p[i] = {ord, total}; } sort(p,p+q); for (ll i = 0;i<q;i++)cout<<p[i].se<<endl; }

Compilation message (stderr)

pilot.cpp: In function 'void rem(ll)':
pilot.cpp:12:19: error: reference to 'ranges' is ambiguous
   12 |     ll l = 0, r = ranges.size()-1;
      |                   ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:16:13: error: reference to 'ranges' is ambiguous
   16 |         if (ranges[m].fi <= idx && idx <= ranges[m].se) break;
      |             ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:16:43: error: reference to 'ranges' is ambiguous
   16 |         if (ranges[m].fi <= idx && idx <= ranges[m].se) break;
      |                                           ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:21:25: error: reference to 'ranges' is ambiguous
   21 |     pair<ll,ll> range = ranges[m];
      |                         ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:23:9: error: reference to 'ranges' is ambiguous
   23 |         ranges[m].fi = idx+1;
      |         ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:25:9: error: reference to 'ranges' is ambiguous
   25 |         ranges[m].se = idx-1;
      |         ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:27:9: error: reference to 'ranges' is ambiguous
   27 |         ranges.insert(ranges.begin()+m+1,{idx+1,ranges[m].se});
      |         ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:27:23: error: reference to 'ranges' is ambiguous
   27 |         ranges.insert(ranges.begin()+m+1,{idx+1,ranges[m].se});
      |                       ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:27:49: error: reference to 'ranges' is ambiguous
   27 |         ranges.insert(ranges.begin()+m+1,{idx+1,ranges[m].se});
      |                                                 ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:28:9: error: reference to 'ranges' is ambiguous
   28 |         ranges[m].se = idx;
      |         ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp: In function 'int main()':
pilot.cpp:38:5: error: reference to 'ranges' is ambiguous
   38 |     ranges.push_back({0,n});
      |     ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~
pilot.cpp:59:25: error: reference to 'ranges' is ambiguous
   59 |         for (auto range:ranges){
      |                         ^~~~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from pilot.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
pilot.cpp:9:21: note:                 'std::vector<std::pair<long long int, long long int> > ranges'
    9 | vector<pair<ll,ll>> ranges;
      |                     ^~~~~~