Submission #781675

#TimeUsernameProblemLanguageResultExecution timeMemory
781675kebineStrange Device (APIO19_strange_device)C++17
0 / 100
5064 ms524288 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fi first
#define se second
#define pb push_back
#define TC int t; cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
//*AC BERSAMA ALLAH  FORTIS FORTUNA ADIUVAT
//# nyampah

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

    ll n,a,b; 
    cin>>n>>a>>b;

    set<pair<ll,ll> > sp, lr;
    for(int i=0;i<n;i++){
        ll l,r; cin>>l>>r;
        if(lr.empty()){
            lr.insert(make_pair(l*-1,r));
        }
        else{
            pair<ll,ll> tmp=*lr.lower_bound(make_pair(-1*l,r));
            if(l>tmp.se || r<tmp.fi*-1){ //diluar
                lr.insert(make_pair(-1*l,r));
            }
            else if(l>=tmp.fi*-1 && r<=tmp.se){
                continue;
            }
            else{
                cout<<"C \n";
                lr.erase(tmp);
                if(l>tmp.fi*-1) l=tmp.fi*-1;
                if(r<tmp.se) r=tmp.se;
                lr.insert(make_pair(l*-1,r));
            }
        }
    }
    for(auto i : lr){
        pair<ll,ll> tmp=i;
        i.fi*=-1;
        for(int j=i.fi;j<=i.se;j++){
            sp.insert(make_pair(((j+j/b)%a),(j%b)));
        }
    }

    cout<<sp.size();

    return 0;
}

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:43:21: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
   43 |         pair<ll,ll> tmp=i;
      |                     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...