Submission #782604

# Submission time Handle Problem Language Result Execution time Memory
782604 2023-07-14T06:24:25 Z andecaandeci Strange Device (APIO19_strange_device) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
ll l[1000005],r[1000005];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>a>>b;
    __int128_t t;
    ll x;
    if ((b+1)%a==0){
        t=b;
    }
    else{
        t=min((__int128_t)a*(__int128_t)b,100000005);
    }
    // cout<<t;
    // t=lcm(t,b);
    set <pair<ll,ll>> st;
    for (int i=1;i<=n;i++){
        cin>>l[i]>>r[i];
        ll u=r[i]-l[i]+1;
        if (u>=t){
            l[i]=0;
            r[i]=t-1;
        }
        else{
            ll q=r[i]-l[i];
            ll p=l[i]%t;
            l[i]=p;
            r[i]=l[i]+q;
        }
        if (r[i]<=t-1){
            st.insert({l[i],r[i]});
            // cout<<l[i]<<" "<<r[i]<<endl;
        }
        else{
            st.insert({l[i],t-1});
            // cout<<l[i]<<" "<<t-1<<endl;
            st.insert({0,(u-(t-l[i]))-1});
            // cout<<0<<" "<<(u-(t-l[i]))-1<<endl;
        }
        // cout<<l[i]<<" "<<r[i]<<endl;
    }
    vector <pair<ll,ll>> pasang;
    for (auto z:st){
        pasang.push_back(z);
    }
    sort(pasang.begin()+1,pasang.begin()+n+1);
    vector <pair<ll,ll>> jawab;
    ll last=pasang[0].second,previous=pasang[0].first;
    pasang.push_back({(ll)1e18+100,(ll)1e18+100});
    sort(pasang.begin(),pasang.end());
    for (int i=1;i<pasang.size();i++){
        if (pasang[i].first<=last){
            last=max(last,pasang[i].second);
        }
        else{
            jawab.push_back({previous,last});
            previous=pasang[i].first;
            last=max(last,pasang[i].second);
        }
    }
    // if (previous>jawab[jawab.size()-1].second){
    //     // jawab.push_back({previous,last});
    // }
    ll ans=0;
    for (int i=0;i<jawab.size();i++){
        ans+=jawab[i].second-jawab[i].first+1;
        // cout<<jawab[i].first<<" "<<jawab[i].second<<":::"<<endl;
    }
    cout<<"  "<<ans;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:15:52: error: no matching function for call to 'min(__int128, int)'
   15 |         t=min((__int128_t)a*(__int128_t)b,100000005);
      |                                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
strange_device.cpp:15:52: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'int')
   15 |         t=min((__int128_t)a*(__int128_t)b,100000005);
      |                                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
strange_device.cpp:15:52: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'int')
   15 |         t=min((__int128_t)a*(__int128_t)b,100000005);
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
strange_device.cpp:15:52: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   15 |         t=min((__int128_t)a*(__int128_t)b,100000005);
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
strange_device.cpp:15:52: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   15 |         t=min((__int128_t)a*(__int128_t)b,100000005);
      |                                                    ^
strange_device.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i=1;i<pasang.size();i++){
      |                  ~^~~~~~~~~~~~~~
strange_device.cpp:68:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for (int i=0;i<jawab.size();i++){
      |                  ~^~~~~~~~~~~~~
strange_device.cpp:10:8: warning: unused variable 'x' [-Wunused-variable]
   10 |     ll x;
      |        ^