Submission #440400

# Submission time Handle Problem Language Result Execution time Memory
440400 2021-07-02T08:34:02 Z DJeniUp Strange Device (APIO19_strange_device) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll>pairll;
typedef pair<ll,pairll>pairlll;
typedef pair<pairll,pairll>pairllll;
typedef long double ld;
typedef pair<ll,string>pairls;

#define INF 1000000000000007
#define pb push_back
#define fr first
#define sc second

ll n,a,b,m;

struct D{
    ll x,y;
}d[100007],t[400007];

bool mcp(D d1, D d2){
    return d1.x<d2.x;
}

int main()
{
    cin>>n>>a>>b;
    ll k=__gcd(a,b+1);
    k=a/k;
    for(int i=1;i<=n;i++){
        cin>>d[i].x>>d[i].y;
        d[i].y++;
        d[i].x%=(k*b);
        d[i].y%=(k*b);
        m++;
        if(d[i].x<=d[i].y){
            m++;
            t[m]={d[i].x,1};
            m++;
            t[m]={d[i].y,-1};
        }else{
            m++;
            t[m]={d[i].x,1};
            m++;
            t[m]={d[i].y,-1};
            m++;
            t[m]={0,1};
            m++;
            t[m]={k*b,-1};
        }
    }
    sort(t+1,t+1+m,mcp);
    ll r=k*b;
    ll h=0;
    t[0].x=0;
    t[m+1].x=b*k;
    for(int i=1;i<=m+1;i++){
        if(h==0){
            r-=(t[i].x-t[i-1].x);
        }
        h+=(t[i].y);
    }
    cout<<r<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -