답안 #643675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643675 2022-09-22T18:29:12 Z jumpOverTheWall Restore Array (RMI19_restore) C++14
100 / 100
521 ms 972 KB
#include <bits/stdc++.h>
using namespace std;

template <class X, class Y>
bool cmin(X &a, const Y &b) {
    return a > b ? a = b, 1 : 0;
}

#define eb emplace_back

struct edge {
    int u, v, w;
    
    edge(int u, int v, int w):
    u(u), v(v), w(w) {}
};

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m; cin >> n >> m;
    vector <int> d(n + 1, 1e9);
    vector <edge> ed; d[0] = 0;
    for (int i = 1; i <= n; i++) {
        ed.eb(i - 1, i, 1);
        ed.eb(i, i - 1, 0);
    }
    for (int i = 0; i < m; i++) {
        int l, r, k, v;
        cin >> l >> r >> k >> v;
        if (!v) ed.eb(r + 1, l, -k);
        else ed.eb(l, r + 1, k - 1);
    }
    for (int i = 0; i < n; i++)
        for (edge e : ed)
            cmin(d[e.v], d[e.u] + e.w);
    for (edge e : ed)
        if (cmin(d[e.v], d[e.u] + e.w)) {
            cout << "-1\n"; return 0;
        }
    for (int i = 1; i <= n; i++)
        cout << 1 - d[i] + d[i - 1] << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 916 KB Output is correct
2 Correct 101 ms 912 KB Output is correct
3 Correct 99 ms 916 KB Output is correct
4 Correct 104 ms 916 KB Output is correct
5 Correct 521 ms 916 KB Output is correct
6 Correct 489 ms 916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 916 KB Output is correct
2 Correct 101 ms 912 KB Output is correct
3 Correct 99 ms 916 KB Output is correct
4 Correct 104 ms 916 KB Output is correct
5 Correct 521 ms 916 KB Output is correct
6 Correct 489 ms 916 KB Output is correct
7 Correct 110 ms 916 KB Output is correct
8 Correct 105 ms 916 KB Output is correct
9 Correct 102 ms 916 KB Output is correct
10 Correct 100 ms 916 KB Output is correct
11 Correct 300 ms 916 KB Output is correct
12 Correct 297 ms 916 KB Output is correct
13 Correct 118 ms 908 KB Output is correct
14 Correct 122 ms 960 KB Output is correct
15 Correct 118 ms 908 KB Output is correct
16 Correct 109 ms 908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 101 ms 916 KB Output is correct
12 Correct 101 ms 912 KB Output is correct
13 Correct 99 ms 916 KB Output is correct
14 Correct 104 ms 916 KB Output is correct
15 Correct 521 ms 916 KB Output is correct
16 Correct 489 ms 916 KB Output is correct
17 Correct 110 ms 916 KB Output is correct
18 Correct 105 ms 916 KB Output is correct
19 Correct 102 ms 916 KB Output is correct
20 Correct 100 ms 916 KB Output is correct
21 Correct 300 ms 916 KB Output is correct
22 Correct 297 ms 916 KB Output is correct
23 Correct 118 ms 908 KB Output is correct
24 Correct 122 ms 960 KB Output is correct
25 Correct 118 ms 908 KB Output is correct
26 Correct 109 ms 908 KB Output is correct
27 Correct 106 ms 916 KB Output is correct
28 Correct 106 ms 904 KB Output is correct
29 Correct 101 ms 972 KB Output is correct
30 Correct 125 ms 916 KB Output is correct
31 Correct 100 ms 916 KB Output is correct
32 Correct 100 ms 916 KB Output is correct
33 Correct 361 ms 916 KB Output is correct
34 Correct 358 ms 912 KB Output is correct
35 Correct 113 ms 916 KB Output is correct
36 Correct 108 ms 916 KB Output is correct