Submission #424552

# Submission time Handle Problem Language Result Execution time Memory
424552 2021-06-12T05:26:21 Z lyc Treatment Project (JOI20_treatment) C++14
35 / 100
2444 ms 205260 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef pair<int,int> ii;

const int mxM = 100001;

int N, M;
struct Treat {
    int T, L, R, C;
} treat[mxM];

int am[5001][5001];
ll dist[mxM];
int vis[mxM];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> N >> M;
    FOR(i,1,M){
        int T, L, R, C;
        cin >> T >> L >> R >> C;
        treat[i] = {T,L,R,C};
    }

    FOR(i,1,M){
        FOR(j,1,M) if (i != j) {
            auto x = treat[i], y = treat[j];
            if (x.R-abs(y.T-x.T) >= y.L-1) am[i][j] = y.C;
            else am[i][j] = -1;
        }
    }

    memset(dist,-1,sizeof dist);
    memset(vis,0,sizeof vis);
    FOR(i,1,M) if (treat[i].L == 1) dist[i] = treat[i].C;
    while (true) {
        int u = -1;
        FOR(i,1,M) if (!vis[i] && dist[i] != -1) {
            if (u == -1 || dist[i] < dist[u]) u = i;
        }
        if (u == -1) break;
        vis[u] = 1;
        if (treat[u].R == N) {
            cout << dist[u] << '\n';
            return 0;
        }

        FOR(v,1,M) if (am[u][v] != -1) {
            ll cur = dist[u]+am[u][v];
            if (dist[v] == -1 || cur < dist[v]) dist[v] = cur;
        }
    }

    cout << -1 << '\n';
}
# Verdict Execution time Memory Grader output
1 Runtime error 2444 ms 205260 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 2 ms 1484 KB Output is correct
3 Correct 1 ms 1476 KB Output is correct
4 Correct 1 ms 1484 KB Output is correct
5 Correct 1 ms 1512 KB Output is correct
6 Correct 1 ms 1484 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 1 ms 1484 KB Output is correct
15 Correct 1 ms 1484 KB Output is correct
16 Correct 1 ms 1472 KB Output is correct
17 Correct 1 ms 1484 KB Output is correct
18 Correct 2 ms 1484 KB Output is correct
19 Correct 2 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 2 ms 1484 KB Output is correct
3 Correct 1 ms 1476 KB Output is correct
4 Correct 1 ms 1484 KB Output is correct
5 Correct 1 ms 1512 KB Output is correct
6 Correct 1 ms 1484 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 1 ms 1484 KB Output is correct
15 Correct 1 ms 1484 KB Output is correct
16 Correct 1 ms 1472 KB Output is correct
17 Correct 1 ms 1484 KB Output is correct
18 Correct 2 ms 1484 KB Output is correct
19 Correct 2 ms 1484 KB Output is correct
20 Correct 266 ms 99640 KB Output is correct
21 Correct 270 ms 99536 KB Output is correct
22 Correct 167 ms 99592 KB Output is correct
23 Correct 138 ms 99500 KB Output is correct
24 Correct 115 ms 99552 KB Output is correct
25 Correct 148 ms 99568 KB Output is correct
26 Correct 145 ms 99624 KB Output is correct
27 Correct 141 ms 99664 KB Output is correct
28 Correct 120 ms 99500 KB Output is correct
29 Correct 193 ms 99720 KB Output is correct
30 Correct 86 ms 99524 KB Output is correct
31 Correct 82 ms 99628 KB Output is correct
32 Correct 187 ms 99584 KB Output is correct
33 Correct 118 ms 99576 KB Output is correct
34 Correct 281 ms 99584 KB Output is correct
35 Correct 179 ms 99616 KB Output is correct
36 Correct 113 ms 99472 KB Output is correct
37 Correct 280 ms 99556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2444 ms 205260 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -