답안 #567967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567967 2022-05-24T12:31:45 Z shrimb Restore Array (RMI19_restore) C++17
0 / 100
278 ms 1360 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 | //\
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 278 ms 1360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 278 ms 1360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -