Submission #784474

# Submission time Handle Problem Language Result Execution time Memory
784474 2023-07-16T07:11:14 Z makanhulia Strange Device (APIO19_strange_device) C++17
5 / 100
579 ms 64216 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
//*AC BERSAMA ALLAH  FORTIS FORTUNA ADIUVAT
//# nyampah
ull sz;
vector<pair<ll,bool> > lr;
vector<pair<ll,ll> > lr1;
ull n, a, b;

ll gcd(ull x, ull y){
    if(y==0) return x;
    else return gcd(x,y%x);
}

ll szz(ull x, ull y){
    if((y+1)%a==0) return y+1;
    else{
        return (x*y);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin>>n>>a>>b;
    sz = abs(szz(a,b));
    // if((b+1)%a==0) sz=b+1;
    // else sz = a*b;

    for(int i=0;i<n;i++){
        ll l,r; cin>>l>>r;
        l%=sz; r%=sz;
        if(l>r){
            lr.pb(make_pair(0,0)); lr.pb(make_pair(r,1));
            lr.pb(make_pair(l,0)); lr.pb(make_pair(sz-1,1));
            // cout<<"-"<<0<<" "<<r<<'\n';
            // cout<<"--"<<l<<" "<<sz-1<<'\n';
        }
        else {
            lr.pb(make_pair(l,0)); lr.pb(make_pair(r,1));
        }
    }
    sort(lr.begin(),lr.end());

    ll cnt=0, l, r;
    for(auto i : lr){
        if(i.se == 0){
            if(cnt==0) l=i.fi;
            cnt++;
        }
        else cnt--;
        
        if(cnt==0){
            r = i.fi;
            lr1.pb(make_pair(l,r));
        }
    }
    cout<<'\n';

    ll ans=0;
    for(auto i : lr1){
        ans+=(i.second-i.first+1);
    }
    cout<<ans<<'\n';


    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare]
   35 |     for(int i=0;i<n;i++){
      |                 ~^~
strange_device.cpp:60:33: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |             lr1.pb(make_pair(l,r));
      |                                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 1036 KB Output is correct
3 Correct 4 ms 980 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 265 ms 33324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 425 ms 63976 KB Output is correct
3 Incorrect 388 ms 64184 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 425 ms 63976 KB Output is correct
3 Incorrect 388 ms 64184 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 425 ms 63976 KB Output is correct
3 Incorrect 388 ms 64184 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 49 ms 7448 KB Output is correct
3 Correct 46 ms 7312 KB Output is correct
4 Correct 579 ms 64216 KB Output is correct
5 Correct 45 ms 7268 KB Output is correct
6 Correct 49 ms 7256 KB Output is correct
7 Correct 46 ms 7228 KB Output is correct
8 Correct 48 ms 7316 KB Output is correct
9 Correct 44 ms 7300 KB Output is correct
10 Correct 60 ms 7340 KB Output is correct
11 Correct 46 ms 7272 KB Output is correct
12 Correct 40 ms 7244 KB Output is correct
13 Correct 47 ms 7292 KB Output is correct
14 Correct 491 ms 64144 KB Output is correct
15 Incorrect 47 ms 7228 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 1036 KB Output is correct
3 Correct 4 ms 980 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -