답안 #233191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233191 2020-05-19T20:41:35 Z duality 치료 계획 (JOI20_treatment) C++11
35 / 100
1167 ms 524292 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

struct pro { int t,l,r,c; };
bool comp(pro a,pro b) {
    return a.t < b.t;
}
pro p[100000];
vpii adjList[100002];
LLI dist[100002];
priority_queue<pair<LLI,int> > H;
int main() {
    int i;
    int N,M;
    scanf("%d %d",&N,&M);
    for (i = 0; i < M; i++) scanf("%d %d %d %d",&p[i].t,&p[i].l,&p[i].r,&p[i].c),p[i].l--,p[i].r--;
    sort(p,p+M,comp);

    int j;
    for (i = 0; i < M; i++) {
        if (p[i].l == 0) adjList[0].pb(mp(i+2,p[i].c));
        if (p[i].r == N-1) adjList[i+2].pb(mp(1,0));
        for (j = 0; j < M; j++) {
            if (i == j) continue;
            if (p[i].r-p[j].l+1 >= abs(p[i].t-p[j].t)) {
                adjList[i+2].pb(mp(j+2,p[j].c));
                //cout<<i<<","<<j<<endl;
            }/*
            else if ((p[j].l >= p[i].l) && (p[i].r-p[j].l+1 >= abs(p[i].t-p[j].t))) {
                adjList[i+2].pb(mp(j+2,p[j].c));
                //cout<<i<<","<<j<<endl;
            }*/
        }
    }
    for (i = 0; i < M+2; i++) dist[i] = -1;
    dist[0] = 0,H.push(mp(0,0));
    while (!H.empty()) {
        int u = H.top().second;
        LLI d = -H.top().first;
        H.pop();

        if (d > dist[u]) continue;
        for (i = 0; i < adjList[u].size(); i++) {
            int v = adjList[u][i].first;
            if ((dist[v] == -1) || (dist[u]+adjList[u][i].second < dist[v])) {
                dist[v] = dist[u]+adjList[u][i].second;
                H.push(mp(-dist[v],v));
            }
        }
    }
    printf("%lld\n",dist[1]);

    return 0;
}

Compilation message

treatment.cpp: In function 'int main()':
treatment.cpp:97:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < adjList[u].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~~~~
treatment.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&N,&M);
     ~~~~~^~~~~~~~~~~~~~~
treatment.cpp:70:90: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < M; i++) scanf("%d %d %d %d",&p[i].t,&p[i].l,&p[i].r,&p[i].c),p[i].l--,p[i].r--;
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1167 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 6 ms 2688 KB Output is correct
20 Correct 278 ms 135160 KB Output is correct
21 Correct 271 ms 135208 KB Output is correct
22 Correct 49 ms 5624 KB Output is correct
23 Correct 48 ms 5624 KB Output is correct
24 Correct 216 ms 94840 KB Output is correct
25 Correct 166 ms 66808 KB Output is correct
26 Correct 158 ms 63736 KB Output is correct
27 Correct 175 ms 79224 KB Output is correct
28 Correct 209 ms 93944 KB Output is correct
29 Correct 157 ms 65912 KB Output is correct
30 Correct 160 ms 73592 KB Output is correct
31 Correct 167 ms 79864 KB Output is correct
32 Correct 262 ms 122872 KB Output is correct
33 Correct 387 ms 191792 KB Output is correct
34 Correct 268 ms 121848 KB Output is correct
35 Correct 264 ms 123192 KB Output is correct
36 Correct 398 ms 191480 KB Output is correct
37 Correct 270 ms 122108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1167 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -