제출 #1128830

#제출 시각아이디문제언어결과실행 시간메모리
1128830mnbvcxz123Restore Array (RMI19_restore)C++20
100 / 100
272 ms808 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 1e4 + 5; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int N, M; cin >> N >> M; vector<tuple<int, int, int>> edges; for(int i = 0; i < M; ++i){ int l, r, k, v; cin >> l >> r >> k >> v; ++r; if(v == 0){ edges.emplace_back(l, r, -k); } else{ edges.emplace_back(r, l, k - 1); } } for(int i = 0; i < N; ++i){ edges.emplace_back(i + 1, i, 1); edges.emplace_back(i, i + 1, 0); } const int inf = 1e9; vector<int> f(N + 1, inf); f[0] = 0; for(int rep = 0; rep < N; ++rep){ for(auto [u, v, w] : edges){ if(f[v] > f[u] + w){ f[v] = f[u] + w; } } } for(auto [u, v, w] : edges){ if(f[v] > f[u] + w){ cout << -1 << '\n'; return 0; } } for(int i = 0; i < N; ++i){ cout << (f[i + 1] - f[i] < 0 ? 0 : 1) << ' '; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...