Submission #782598

# Submission time Handle Problem Language Result Execution time Memory
782598 2023-07-14T06:19:26 Z kebine 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){
        if (b>1000005){
            t=1000005;
        }
        else
            t=b;
    }
    else{
        if (b>1000005||a>1000005||a*b>1000005){
            t=1000005;
        }
        else
            t=a*b;
    }
    // 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:47:28: error: ambiguous overload for 'operator<<' (operand types are 'std::basic_ostream<char>' and '__int128')
   47 |             cout<<l[i]<<" "<<t-1<<endl;
      |             ~~~~~~~~~~~~~~~^~~~~
      |                       |       |
      |                       |       __int128
      |                       std::basic_ostream<char>
In file included from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from strange_device.cpp:1:
/usr/include/c++/10/ostream:166:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  166 |       operator<<(long __n)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:170:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  170 |       operator<<(unsigned long __n)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  174 |       operator<<(bool __n)
      |       ^~~~~~~~
In file included from /usr/include/c++/10/ostream:784,
                 from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/ostream.tcc:91:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
   91 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from strange_device.cpp:1:
/usr/include/c++/10/ostream:181:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  181 |       operator<<(unsigned short __n)
      |       ^~~~~~~~
In file included from /usr/include/c++/10/ostream:784,
                 from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/ostream.tcc:105:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
  105 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from strange_device.cpp:1:
/usr/include/c++/10/ostream:192:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  192 |       operator<<(unsigned int __n)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:201:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  201 |       operator<<(long long __n)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:205:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  205 |       operator<<(unsigned long long __n)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:220:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  220 |       operator<<(double __f)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:224:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  224 |       operator<<(float __f)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:232:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]'
  232 |       operator<<(long double __f)
      |       ^~~~~~~~
/usr/include/c++/10/ostream:511:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT = char; _Traits = std::char_traits<char>]'
  511 |     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:517:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char) [with _Traits = std::char_traits<char>]'
  517 |     operator<<(basic_ostream<char, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:523:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char) [with _Traits = std::char_traits<char>]'
  523 |     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
      |     ^~~~~~~~
/usr/include/c++/10/ostream:528:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]'
  528 |     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
      |     ^~~~~~~~
strange_device.cpp:62: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]
   62 |     for (int i=1;i<pasang.size();i++){
      |                  ~^~~~~~~~~~~~~~
strange_device.cpp:76: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]
   76 |     for (int i=0;i<jawab.size();i++){
      |                  ~^~~~~~~~~~~~~
strange_device.cpp:10:8: warning: unused variable 'x' [-Wunused-variable]
   10 |     ll x;
      |        ^