답안 #259925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259925 2020-08-08T19:53:53 Z thebes 치료 계획 (JOI20_treatment) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
#define F first
#define S second

const int MN = 1e5+5;
const ll inf = 1e12;
ll N, M, i, j, x, y, c, t, dis[MN], vs[MN], ans=1LL<<60;
struct idk{ll a,b,c,d;}arr[MN],go[MN];
map<ll,ll> mpx, mpy; vector<ll> ed;
struct pq{bool operator()(const pll&i,const pll&j){return i.S>j.S;}};
priority_queue<pll,vector<pll>,pq> q;

struct segtree{
    set<pii> st[6*MN]; ll n, c;
    void init(ll N){n=N;}
    void upd(ll i,ll s,ll e,ll ss,ll se,ll val,ll id){
        st[i].insert({val,id});
        if(s==e) return;
        else if((s+e)/2<ss) upd(2*i+1,(s+e)/2+1,e,ss,se,val,id);
        else if((s+e)/2>=se) upd(2*i,s,(s+e)/2,ss,se,val,id);
        else upd(2*i,s,(s+e)/2,ss,se,val,id), upd(2*i+1,(s+e)/2+1,e,ss,se,val,id);
    }
    inline void update(ll s,ll e,ll c,ll id){
        upd(1,1,n,s,e,c,id);
    }
    void qu(ll i,ll s,ll e,ll ss,ll se,ll a,ll b){
        if(s>=ss&&e<=se){
            auto it=st[i].lower_bound({a,0});
            while(it!=st[i].end()&&it->first<=b){
                if(!vs[it->second]){
                    vs[it->second]=1;
                    q.push({it->second,c+arr[it->second].c});
                }
                auto it2=it; it++;
                st[i].erase(it2);
            }
        }
        else if((s+e)/2<ss) qu(2*i+1,(s+e)/2+1,e,ss,se,a,b);
        else if((s+e)/2>=se) qu(2*i,s,(s+e)/2,ss,se,a,b);
        else qu(2*i,s,(s+e)/2,ss,se,a,b),qu(2*i+1,(s+e)/2+1,e,ss,se,a,b);
    }
    inline void query(ll s,ll e,ll x,ll y,ll cur){
        c = cur;
        qu(1,1,n,s,e,x,y);
    }
}stx, sty;

int main(){
    scanf("%lld%lld",&N,&M);
    for(i=1;i<=M;i++){
        scanf("%lld%lld%lld%lld",&t,&x,&y,&c);
        arr[i]={x,y,c,t};
        if(x==1) q.push({i,c}), x=-inf, vs[i]=1;
        if(y==N) ed.push_back(i), y=inf;
        y++;
        ll sx = t-y, ex = t-x;
        ll sy = t+x, ey = t+y;
        go[i]={sx,ex,sy,ey};
        mpx[sx]=mpx[ex]=mpy[sy]=mpy[ey]=0;
    }
    i=0; stx.init(mpx.size());
    for(auto it=mpx.begin();it!=mpx.end();it++)
        it->second = ++i;
    i=0; sty.init(mpy.size());
    for(auto it=mpy.begin();it!=mpy.end();it++)
        it->second = ++i;
    for(i=1;i<=M;i++){
        go[i].a=mpx[go[i].a]; go[i].b=mpx[go[i].b];
        go[i].c=mpy[go[i].c]; go[i].d=mpy[go[i].d];
        stx.update(go[i].a,go[i].b,go[i].c,i);
        stx.update(go[i].a,go[i].b,go[i].d,i);
        sty.update(go[i].c,go[i].d,go[i].a,i);
        sty.update(go[i].c,go[i].d,go[i].b,i);
    }
    memset(dis,-1,sizeof(dis));
    while(q.size()){
        pll x=q.top(); q.pop();
        dis[x.F]=x.S;
        int id = x.F;
        stx.query(go[id].a,go[id].b,go[id].c,go[id].d,x.S);
        sty.query(go[id].c,go[id].d,go[id].a,go[id].b,x.S);
    }
    for(auto v : ed){
        if(dis[v]!=-1) ans=min(ans,dis[v]);
    }
    printf("%lld\n",ans==1LL<<60?-1:ans);
    return 0;
}

Compilation message

treatment.cpp:18:9: error: 'pii' was not declared in this scope
     set<pii> st[6*MN]; ll n, c;
         ^~~
treatment.cpp:18:12: error: template argument 1 is invalid
     set<pii> st[6*MN]; ll n, c;
            ^
treatment.cpp:18:12: error: template argument 2 is invalid
treatment.cpp:18:12: error: template argument 3 is invalid
treatment.cpp: In member function 'void segtree::upd(ll, ll, ll, ll, ll, ll, ll)':
treatment.cpp:21:15: error: request for member 'insert' in '((segtree*)this)->segtree::st[i]', which is of non-class type 'int'
         st[i].insert({val,id});
               ^~~~~~
treatment.cpp: In member function 'void segtree::qu(ll, ll, ll, ll, ll, ll, ll)':
treatment.cpp:32:27: error: request for member 'lower_bound' in '((segtree*)this)->segtree::st[i]', which is of non-class type 'int'
             auto it=st[i].lower_bound({a,0});
                           ^~~~~~~~~~~
treatment.cpp:33:29: error: request for member 'end' in '((segtree*)this)->segtree::st[i]', which is of non-class type 'int'
             while(it!=st[i].end()&&it->first<=b){
                             ^~~
treatment.cpp:36:60: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, pq>::push(<brace-enclosed initializer list>)'
                     q.push({it->second,c+arr[it->second].c});
                                                            ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from treatment.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:595:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = pq; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long int>]
       push(const value_type& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:595:7: 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>&}'
/usr/include/c++/7/bits/stl_queue.h:603:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = pq; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long int>]
       push(value_type&& __x)
       ^~~~
/usr/include/c++/7/bits/stl_queue.h:603:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, pq>::value_type&& {aka std::pair<long long int, long long int>&&}'
treatment.cpp:38:26: error: unable to deduce 'auto' from 'it'
                 auto it2=it; it++;
                          ^~
treatment.cpp:39:23: error: request for member 'erase' in '((segtree*)this)->segtree::st[i]', which is of non-class type 'int'
                 st[i].erase(it2);
                       ^~~~~
treatment.cpp: In function 'int main()':
treatment.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&N,&M);
     ~~~~~^~~~~~~~~~~~~~~~~~
treatment.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld%lld",&t,&x,&y,&c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~