이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]) << " ";
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
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) {
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |