답안 #1043316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043316 2024-08-04T08:13:10 Z TrinhKhanhDung 치료 계획 (JOI20_treatment) C++14
0 / 100
29 ms 13264 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(1e9 + 7)

using namespace std;

template<class T1, class T2>
    bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

template<class T1, class T2>
    bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}

template<class T1, class T2>
    void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}

template<class T1, class T2>
    void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}

template<class T>
    void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}

const int MAX = 1e5 + 5;

int N, M;
int T[MAX], L[MAX], R[MAX], C[MAX], rnk[MAX];
bool vis[MAX];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> adj1[MAX];
priority_queue<pair<int, int>> adj2[MAX];

void solve(){
    cin >> N >> M;
    vector<int> v;
    for(int i=1; i<=M; i++){
        cin >> T[i] >> L[i] >> R[i] >> C[i];
        v.push_back(T[i]);
    }
    cps(v);
    for(int i=1; i<=M; i++){
        int p = lower_bound(ALL(v), T[i]) - v.begin() + 1;
        rnk[i] = p;
        for(int k=p; k>0; k-=k&(-k)){
            adj1[k].push(make_pair(L[i] + T[i], i));
        }
        for(int k=p; k<=sz(v); k+=k&(-k)){
            adj2[k].push(make_pair(T[i] - L[i], i));
        }
    }

//    //Dijkstra
//    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
//    for(int i=1; i<=N; i++){
//        if(L[i] == 1){
//            pq.push(make_pair(C[i], i));
//            vis[i] = true;
//        }
//    }
//
//    while(sz(pq)){
//        int u = pq.top().se;
//        ll c = pq.top().fi;
//        if(R[u] == N){
//            cout << c << '\n';
//            return;
//        }
//        pq.pop();
//        int k = rnk[u];
//        for(int p=k; p<=sz(v); p+=p&(-p)){
//            while(sz(adj1[p])){
//                int v = adj1[p].top().se;
//                int tmp = adj1[p].top().fi;
//                if(tmp > R[u] + T[u] + 1) break;
//                adj1[p].pop();
//                if(vis[v]) continue;
//                vis[v] = true;
//                pq.push(make_pair(c + C[v], v));
//            }
//        }
//        for(int p=k; p>0; p-=p&(-p)){
//            while(sz(adj2[p])){
//                int v = adj2[p].top().se;
//                int tmp = adj2[p].top().fi;
//                if(tmp < T[u] - R[u] - 1) break;
//                adj2[p].pop();
//                if(vis[v]) continue;
//                vis[v] = true;
//                pq.push(make_pair(c + C[v], v));
//            }
//        }
//    }
    cout << -1 << '\n';
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
//    freopen("deggraph.inp", "r", stdin);
//    freopen("deggraph.out", "w", stdout);

    int t = 1;
//    cin >> t;
    while(t--){
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 13264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 13264 KB Output isn't correct
2 Halted 0 ms 0 KB -