답안 #697053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697053 2023-02-08T04:05:47 Z Cross_Ratio 치료 계획 (JOI20_treatment) C++14
35 / 100
995 ms 524288 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const ll INF = 1e18;
int T[100005];
int L[100005];
int R[100005];
ll C[100005];
vector<vector<array<ll, 2>>> adj;
ll dis[200005];
bool vis[200005];
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N, M;
    cin >> N >> M;
    int i, j;
    for(i=1;i<=M;i++) {
        cin >> T[i] >> L[i] >> R[i] >> C[i];
    }
    //0 is left, 1 is right
    //2i is input, 2i+1 is output
    adj.resize(2*M+2);
    for(i=1;i<=M;i++) {
        adj[2*i].push_back({2*i+1, C[i]});
        if(L[i]==1) adj[0].push_back({2*i, 0});
        if(R[i]==N) adj[2*i+1].push_back({1, 0});
    }
    for(i=1;i<=M;i++) {
        for(j=1;j<=M;j++) {
            if(i==j) continue;
            if(T[i] >= T[j]) {
                int t = T[i] - T[j];
                if(R[j] == N || L[i] <= R[j] - t + 1) {
                    adj[2*j+1].push_back({2*i, 0});
                }
            }
            if(T[i] <= T[j]) {
                int t = T[j] - T[i];
                if(L[i] == 1 || L[i] - 1 + t <= R[j]) {
                    adj[2*j+1].push_back({2*i, 0});
                }
            }
        }
    }
    /*for(i=0;i<=2*M+1;i++) {
        cout << i << " : ";
        for(auto n2 : adj[i]) {
            cout << "(" << n2[0] << ", " << n2[1] << ") ";
        }
        cout << '\n';
    }*/
    for(i=0;i<=2*M+1;i++) dis[i] = INF;
    dis[0] = 0;
    while(true) {
        ll mi = INF, pt = -1;
        for(i=0;i<=2*M+1;i++) {
            if(!vis[i] && mi > dis[i]) {
                mi = dis[i];
                pt = i;
            }
        }
        if(pt==-1) break;
        vis[pt] = true;
        for(auto n2 : adj[pt]) {
            if(dis[n2[0]] > dis[pt] + n2[1]) {
                dis[n2[0]] = dis[pt] + n2[1];
            }
        }
    }
    cout << (dis[1]==INF?-1:dis[1]);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 995 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 268 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 268 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 727 ms 347032 KB Output is correct
21 Correct 749 ms 346460 KB Output is correct
22 Correct 319 ms 8888 KB Output is correct
23 Correct 250 ms 8944 KB Output is correct
24 Correct 477 ms 219528 KB Output is correct
25 Correct 328 ms 142436 KB Output is correct
26 Correct 275 ms 134348 KB Output is correct
27 Correct 289 ms 158028 KB Output is correct
28 Correct 460 ms 217912 KB Output is correct
29 Correct 334 ms 140800 KB Output is correct
30 Correct 215 ms 152968 KB Output is correct
31 Correct 191 ms 162192 KB Output is correct
32 Correct 656 ms 317232 KB Output is correct
33 Correct 729 ms 441788 KB Output is correct
34 Correct 619 ms 260032 KB Output is correct
35 Correct 667 ms 320100 KB Output is correct
36 Correct 744 ms 438336 KB Output is correct
37 Correct 633 ms 259548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 995 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -