Submission #219377

# Submission time Handle Problem Language Result Execution time Memory
219377 2020-04-05T08:08:16 Z ho94949 Treatment Project (JOI20_treatment) C++17
35 / 100
315 ms 196600 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXM = 5000;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
int N, M;
int T[MAXM+2], L[MAXM+2], R[MAXM+2], C[MAXM+2];
int XL[MAXM+2], YL[MAXM+2], XR[MAXM+2], YR[MAXM+2];
long long cost[MAXM+2][MAXM+2];
long long dist[MAXM+2];
bool vis[MAXM+2];
long long dijk(int N, int s, int e)
{
    memset(dist, 0x3f, sizeof dist);
    memset(vis, 0, sizeof vis);
    dist[s] = 0;
    for(int _=0; _<N; _++)
    {
        int mini = -1; long long minv = INF;
        for(int i=0; i<N; ++i)
            if(!vis[i] && minv>dist[i])
                mini = i, minv = dist[i];
        if(mini == -1) return -1;
        if(mini == e) return minv;
        vis[mini] = true;
        for(int i=0; i<N; ++i)
            dist[i] = min(dist[i], dist[mini]+cost[mini][i]);
    }
    return -1;
}
int main()
{
    scanf("%d%d", &N, &M);
    for(int i=1; i<=M; ++i)
    {
        scanf("%d%d%d%d", T+i, L+i, R+i, C+i);
        --L[i]; //L[i] = 0, R[i] = N covers whole
        XL[i] = L[i]-T[i], YL[i] = L[i]+T[i];
        XR[i] = R[i]-T[i], YR[i] = R[i]+T[i];
    }
    memset(cost, 0x3f, sizeof cost);
    for(int i=1; i<=M; ++i)
    {
        if(L[i] == 0) cost[0][i] = C[i];
        if(R[i] == N) cost[i][M+1] = 0;
    }
    for(int i=1; i<=M; ++i)
    {
        for(int j=1; j<=M; ++j)
        {
            if(i==j) continue;
            if(XL[j] <= XR[i] && YL[j] <= YR[i])
                cost[i][j] = C[j];
        }
    }
    long long ans = dijk(M+2, 0, M+1);
    printf("%lld\n", ans);
}

Compilation message

treatment.cpp: In function 'int main()':
treatment.cpp:32: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:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", T+i, L+i, R+i, C+i);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 196600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 100 ms 196216 KB Output is correct
2 Correct 97 ms 196216 KB Output is correct
3 Correct 98 ms 196216 KB Output is correct
4 Correct 97 ms 196216 KB Output is correct
5 Correct 103 ms 196216 KB Output is correct
6 Correct 97 ms 196216 KB Output is correct
7 Correct 97 ms 196216 KB Output is correct
8 Correct 96 ms 196216 KB Output is correct
9 Correct 100 ms 196216 KB Output is correct
10 Correct 99 ms 196192 KB Output is correct
11 Correct 100 ms 196216 KB Output is correct
12 Correct 97 ms 196216 KB Output is correct
13 Correct 97 ms 196216 KB Output is correct
14 Correct 104 ms 196216 KB Output is correct
15 Correct 99 ms 196216 KB Output is correct
16 Correct 97 ms 196216 KB Output is correct
17 Correct 97 ms 196216 KB Output is correct
18 Correct 98 ms 196216 KB Output is correct
19 Correct 101 ms 196472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 196216 KB Output is correct
2 Correct 97 ms 196216 KB Output is correct
3 Correct 98 ms 196216 KB Output is correct
4 Correct 97 ms 196216 KB Output is correct
5 Correct 103 ms 196216 KB Output is correct
6 Correct 97 ms 196216 KB Output is correct
7 Correct 97 ms 196216 KB Output is correct
8 Correct 96 ms 196216 KB Output is correct
9 Correct 100 ms 196216 KB Output is correct
10 Correct 99 ms 196192 KB Output is correct
11 Correct 100 ms 196216 KB Output is correct
12 Correct 97 ms 196216 KB Output is correct
13 Correct 97 ms 196216 KB Output is correct
14 Correct 104 ms 196216 KB Output is correct
15 Correct 99 ms 196216 KB Output is correct
16 Correct 97 ms 196216 KB Output is correct
17 Correct 97 ms 196216 KB Output is correct
18 Correct 98 ms 196216 KB Output is correct
19 Correct 101 ms 196472 KB Output is correct
20 Correct 282 ms 196344 KB Output is correct
21 Correct 282 ms 196300 KB Output is correct
22 Correct 315 ms 196344 KB Output is correct
23 Correct 268 ms 196344 KB Output is correct
24 Correct 173 ms 196344 KB Output is correct
25 Correct 206 ms 196344 KB Output is correct
26 Correct 194 ms 196344 KB Output is correct
27 Correct 188 ms 196344 KB Output is correct
28 Correct 181 ms 196344 KB Output is correct
29 Correct 191 ms 196344 KB Output is correct
30 Correct 134 ms 196344 KB Output is correct
31 Correct 133 ms 196472 KB Output is correct
32 Correct 228 ms 196344 KB Output is correct
33 Correct 159 ms 196344 KB Output is correct
34 Correct 301 ms 196472 KB Output is correct
35 Correct 230 ms 196344 KB Output is correct
36 Correct 165 ms 196344 KB Output is correct
37 Correct 299 ms 196472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 196600 KB Output isn't correct
2 Halted 0 ms 0 KB -