답안 #568117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568117 2022-05-24T16:44:01 Z lacito Restore Array (RMI19_restore) C++14
100 / 100
359 ms 1248 KB
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")

#include "bits/stdc++.h"
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;

#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991

const int maxn = 1000001;

int dist[maxn];

vector<array<int, 3>> E;

signed main () {
    cin.tie(0)->sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    for (int i = 0 ; i < m ; i++) {
        int x, y, k, v;
        cin >> x >> y >> k >> v;
        x++,y++;
        int s = y - x + 1;
        if (v == 1) {
            k--;
            E.push_back({x - 1, y, k - s});
        } else {
            E.push_back({y, x - 1, s - k});
        }
    }

    for (int i = 1 ; i <= n ; i++) dist[i] = INT_MAX;

    for (int i = 0 ; i < n ; i++) {
        E.push_back({i, i + 1, 0});
        E.push_back({i + 1, i, 1});
    }

    for (int iter = 0 ; iter < n ; iter++) {
        for (auto [u,v,w] : E) {
            dist[u] = min(dist[u], dist[v] + w);
        }
    }

    bool imp = 0;

    for (auto [u,v,w] : E) {
        if (dist[u] > dist[v] + w) imp = 1;
    }

    if (imp) cout << -1;
    else {
        for (int i = 1 ; i <= n ; i++) {
            cout << (dist[i] > dist[i-1]) << " ";
        }
    }
}

Compilation message

restore.cpp:17:1: warning: multi-line comment [-Wcomment]
   17 | //\
      | ^
restore.cpp: In function 'int main()':
restore.cpp:53:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   53 |         for (auto [u,v,w] : E) {
      |                   ^
restore.cpp:60:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   60 |     for (auto [u,v,w] : E) {
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 324 ms 1232 KB Output is correct
2 Correct 333 ms 1232 KB Output is correct
3 Correct 323 ms 1232 KB Output is correct
4 Correct 331 ms 1232 KB Output is correct
5 Correct 329 ms 1232 KB Output is correct
6 Correct 315 ms 1232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 324 ms 1232 KB Output is correct
2 Correct 333 ms 1232 KB Output is correct
3 Correct 323 ms 1232 KB Output is correct
4 Correct 331 ms 1232 KB Output is correct
5 Correct 329 ms 1232 KB Output is correct
6 Correct 315 ms 1232 KB Output is correct
7 Correct 358 ms 1232 KB Output is correct
8 Correct 327 ms 1232 KB Output is correct
9 Correct 359 ms 1232 KB Output is correct
10 Correct 326 ms 1232 KB Output is correct
11 Correct 350 ms 1232 KB Output is correct
12 Correct 321 ms 1232 KB Output is correct
13 Correct 340 ms 1232 KB Output is correct
14 Correct 358 ms 1232 KB Output is correct
15 Correct 356 ms 1232 KB Output is correct
16 Correct 342 ms 1232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 324 ms 1232 KB Output is correct
12 Correct 333 ms 1232 KB Output is correct
13 Correct 323 ms 1232 KB Output is correct
14 Correct 331 ms 1232 KB Output is correct
15 Correct 329 ms 1232 KB Output is correct
16 Correct 315 ms 1232 KB Output is correct
17 Correct 358 ms 1232 KB Output is correct
18 Correct 327 ms 1232 KB Output is correct
19 Correct 359 ms 1232 KB Output is correct
20 Correct 326 ms 1232 KB Output is correct
21 Correct 350 ms 1232 KB Output is correct
22 Correct 321 ms 1232 KB Output is correct
23 Correct 340 ms 1232 KB Output is correct
24 Correct 358 ms 1232 KB Output is correct
25 Correct 356 ms 1232 KB Output is correct
26 Correct 342 ms 1232 KB Output is correct
27 Correct 334 ms 1232 KB Output is correct
28 Correct 338 ms 1248 KB Output is correct
29 Correct 335 ms 1232 KB Output is correct
30 Correct 331 ms 1232 KB Output is correct
31 Correct 327 ms 1232 KB Output is correct
32 Correct 333 ms 1232 KB Output is correct
33 Correct 355 ms 1232 KB Output is correct
34 Correct 326 ms 1232 KB Output is correct
35 Correct 340 ms 1232 KB Output is correct
36 Correct 340 ms 1232 KB Output is correct