Submission #567968

# Submission time Handle Problem Language Result Execution time Memory
567968 2022-05-24T12:32:29 Z shrimb Restore Array (RMI19_restore) C++17
0 / 100
276 ms 1232 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) {
            E.push_back({x, y, s - 2*k}); // dist[x] = dist[y] + (s - 2*k)
            // E.push_back({y, x, -(s - 2*k)});
        } else {
            E.push_back({x, y, 2*k - s}); // dist[x] = dist[y] + (2*k - s)
            // E.push_back({y, x, -(2*k - s)});
        }
    }

    for (int i = 1 ; i <= n ; i++) {
        E.push_back({i, i + 1, 1});
        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 | //\
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 276 ms 1232 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 276 ms 1232 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -