답안 #233170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233170 2020-05-19T18:56:46 Z duality 치료 계획 (JOI20_treatment) C++11
0 / 100
3000 ms 4984 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].r == N-1) adjList[0].pb(mp(i+2,p[i].c));
        if (p[i].l == 0) adjList[i+2].pb(mp(1,0));
        for (j = 0; j < i; j++) {
            if ((p[j].l <= p[i].l) && (p[j].r-p[i].l+1 >= p[i].t-p[j].t)) {
                adjList[i+2].pb(mp(j+2,p[j].c));
                //adjList[j+2].pb(mp(i+2,p[i].c));
                //cout<<i<<","<<j<<endl;
            }
            else if ((p[j].l >= p[i].l) && (p[i].r-p[j].l+1 >= p[i].t-p[j].t)) {
                //adjList[i+2].pb(mp(j+2,p[j].c));
                adjList[j+2].pb(mp(i+2,p[i].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:98: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 Execution timed out 3077 ms 4984 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Incorrect 6 ms 2816 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Incorrect 6 ms 2816 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3077 ms 4984 KB Time limit exceeded
2 Halted 0 ms 0 KB -