Submission #1225449

#TimeUsernameProblemLanguageResultExecution timeMemory
1225449AlgorithmWarriorMobile (BOI12_mobile)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ld long double

using namespace std;

struct range{
    ld x,y,l,r;
};

ld special_inters(ld x1,ld y1,ld x2,ld y2){
    return (x1*x1-x2*x2+y1*y1-y2*y2)/(2*(x1-x2));
}

vector<range>ranges;

void get_ranges(){
    int n,len;
    cin>>n>>len;
    int last_x=-1000000001;
    int i;
    for(i=1;i<=n;++i){
        int x,y;
        cin>>x>>y;
        if(x!=last_x){
            last_x=x;
            while(!ranges.empty()){
                auto [px,py,l,r]=ranges.back();
                ld inters=special_inters(x,y,px,py);
                if(r<=inters)
                    break;
                if(inters<=l)
                    ranges.pop_back();
                else{
                    ranges.back().r=inters;
                    break;
                }
            }
            if(ranges.empty())
                ranges.push_back({(ld)x,(ld)y,0,(ld)len});
            else
                ranges.push_back({(ld)x,(ld)y,ranges.back().r,(ld)len});
        }
    }
}

ld dist(ld x1,ld y1,ld x2,ld y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

ld solve(){
    ld mxm=0;
    for(auto [x,y,l,r] : ranges){
        ld dst=dist(x,y,l,0);
        if(mxm<dst)
            mxm=dst;
        dst=dist(x,y,r,0);
        if(mxm<dst)
            mxm=dst;
    }
    return mxm;
}

int main()
{
    get_ranges();
    cout<<fixed<<setprecision(6)<<solve();
    return 0;
}

Compilation message (stderr)

mobile.cpp: In function 'void get_ranges()':
mobile.cpp:26:20: error: reference to 'ranges' is ambiguous
   26 |             while(!ranges.empty()){
      |                    ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp:27:34: error: reference to 'ranges' is ambiguous
   27 |                 auto [px,py,l,r]=ranges.back();
      |                                  ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp:32:21: error: reference to 'ranges' is ambiguous
   32 |                     ranges.pop_back();
      |                     ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp:34:21: error: reference to 'ranges' is ambiguous
   34 |                     ranges.back().r=inters;
      |                     ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp:38:16: error: reference to 'ranges' is ambiguous
   38 |             if(ranges.empty())
      |                ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp:39:17: error: reference to 'ranges' is ambiguous
   39 |                 ranges.push_back({(ld)x,(ld)y,0,(ld)len});
      |                 ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp:41:17: error: reference to 'ranges' is ambiguous
   41 |                 ranges.push_back({(ld)x,(ld)y,ranges.back().r,(ld)len});
      |                 ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp:41:47: error: reference to 'ranges' is ambiguous
   41 |                 ranges.push_back({(ld)x,(ld)y,ranges.back().r,(ld)len});
      |                                               ^~~~~~
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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~
mobile.cpp: In function 'long double solve()':
mobile.cpp:52:26: error: reference to 'ranges' is ambiguous
   52 |     for(auto [x,y,l,r] : 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 mobile.cpp:1:
/usr/include/c++/11/concepts:163:13: note: candidates are: 'namespace std::ranges { }'
  163 |   namespace ranges
      |             ^~~~~~
mobile.cpp:14:14: note:                 'std::vector<range> ranges'
   14 | vector<range>ranges;
      |              ^~~~~~