답안 #403374

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403374 2021-05-13T06:02:28 Z Hazem 이상한 기계 (APIO19_strange_device) C++14
0 / 100
5000 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;
 
#define LL long long
#define F first
#define S second
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>

const int N = 1e6+10;
const int M = 200;
const LL INF = 1e9;
const LL LINF = 2e18;
const LL MOD = 1e9+7;
const double PI = 3.141592653589793;

pair<LL,LL>p[N];
vector<pair<LL,LL>>vec;

struct node{

    node *l,*r;
    LL sum = 0;
    int lazy = 0;
    node():l(NULL),r(NULL){};
};

void push(node * &v,LL tl,LL tr){

    if(v==NULL||!v->lazy)return ;
    v->sum = tr-tl+1;

    if(tl!=tr){
        
        if(v->l==NULL)v->l = new node();
        if(v->r==NULL)v->r = new node();

        v->l->lazy = 1;
        v->r->lazy = 1;    
    }
    v->lazy = 0;
}

void update(node * &v,LL tl,LL tr,LL l,LL r){

    push(v,tl,tr);

    if(tl>r||tr<l)
        return ;
    
    if(v==NULL) v = new node();

    if(tl>=l&&tr<=r){
        v->lazy = 1;
        push(v,tl,tr);
        return ;
    }

    LL mid = (tl+tr)/2;
    update(v->l,tl,mid,l,r);
    update(v->r,mid+1,tr,l,r);
    v->sum = (v->l==NULL?0:v->l->sum)+(v->r==NULL?0:v->r->sum);
}

node *root;

int main(){

    //freopen("out.txt","w",stdout);

    LL n,a,b,Len;
    scanf("%lld%lld%lld",&n,&a,&b);

    if(log(a)+log(b)>=log(LLONG_MAX))    
        Len = LINF;
    else 
        Len = a*b;

    bool q = 0;
    set<LL>st;
    LL ans = 0;
    for(int i=1;i<=n;i++){

        scanf("%lld%lld",&p[i].F,&p[i].S);
        q |= p[i].S-p[i].F+1>=Len;

        p[i].F %= Len;p[i].S %= Len;

        if(p[i].F<=p[i].S)
            //ans += p[i].S-p[i].F+1;
         for(int j=p[i].F;j<=p[i].S;j++)
             st.insert(j);
        
        else {
            
            //ans += Len-p[i].F;
             for(int j=p[i].F;j<=Len-1;j++)
                 st.insert(j);
            
             for(int j=0;j<=p[i].S;j++)
                 st.insert(j);
            //ans += p[i].S+1;
        }

        if(p[i].S>=p[i].F)
            vec.push_back({p[i].F,p[i].S});
        else 
            vec.push_back({p[i].F,Len-1}),vec.push_back({0,p[i].S});
    }

    // sort(vec.begin(),vec.end());
    
    // LL l = 0,r = -1,ans = 0;
    // vec.push_back({LINF,LINF});

    // for(int i=0;i<vec.size();i++){
        
    //     if(vec[i].F>r)
    //         ans += r-l+1,l = vec[i].F,r = vec[i].S;
    //     else 
    //         r = vec[i].S;
    // }

    printf("%lld\n",q?Len:st.size());
}   

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:81:8: warning: unused variable 'ans' [-Wunused-variable]
   81 |     LL ans = 0;
      |        ^~~
strange_device.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |     scanf("%lld%lld%lld",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:84:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         scanf("%lld%lld",&p[i].F,&p[i].S);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 43 ms 9520 KB Output is correct
3 Correct 68 ms 13792 KB Output is correct
4 Incorrect 3 ms 844 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 3687 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 111 ms 24188 KB Output is correct
3 Correct 112 ms 24244 KB Output is correct
4 Correct 106 ms 22916 KB Output is correct
5 Execution timed out 5079 ms 46956 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 713 ms 78484 KB Output is correct
3 Runtime error 3746 ms 524292 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 713 ms 78484 KB Output is correct
3 Runtime error 3746 ms 524292 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 713 ms 78484 KB Output is correct
3 Runtime error 3746 ms 524292 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 2971 ms 524292 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 43 ms 9520 KB Output is correct
3 Correct 68 ms 13792 KB Output is correct
4 Incorrect 3 ms 844 KB Output isn't correct
5 Halted 0 ms 0 KB -