Submission #783501

# Submission time Handle Problem Language Result Execution time Memory
783501 2023-07-15T01:54:00 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];
vector <pair<ll,ll>> pasang;
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,(__int128_t)1e18);
    // }
    t=min((__int128_t)a*(__int128_t)b/gcd(a,b+1),(__int128_t)2e18);
    // 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){
            pasang.push_back({l[i],r[i]});
            // cout<<l[i]<<" "<<r[i]<<endl;
        }
        else{
            pasang.push_back({l[i],t-1});
            // cout<<l[i]<<" "<<t-1<<endl;
            pasang.push_back({0,r[i]%mod});
            // cout<<0<<" "<<(u-(t-l[i]))-1<<endl;
        }
        // cout<<l[i]<<" "<<r[i]<<endl;
    }
    // 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());
    ll ans=0;
    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});
            ans+=last-previous+1;
            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:42:38: error: 'mod' was not declared in this scope; did you mean 'modf'?
   42 |             pasang.push_back({0,r[i]%mod});
      |                                      ^~~
      |                                      modf
strange_device.cpp:42:42: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   42 |             pasang.push_back({0,r[i]%mod});
      |                                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
strange_device.cpp:56: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]
   56 |     for (int i=1;i<pasang.size();i++){
      |                  ~^~~~~~~~~~~~~~
strange_device.cpp:11:8: warning: unused variable 'x' [-Wunused-variable]
   11 |     ll x;
      |        ^