Submission #332473

#TimeUsernameProblemLanguageResultExecution timeMemory
332473IgorIRestore Array (RMI19_restore)C++17
100 / 100
520 ms876 KiB
#include <bits/stdc++.h> using namespace std; const int N = 20300; int f[N], t[N], w[N]; int sz; int d[N]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int l, r, k, v; cin >> l >> r >> k >> v; r++; if (v == 0) { // k-th = zero, at most len-k ones f[sz] = l; t[sz] = r; w[sz] = r - l - k; sz++; } else { // k-th = one, at least len - k + 1 ones f[sz] = r; t[sz] = l; w[sz] = -(r - l - k + 1); sz++; } } for (int i = 0; i < n; i++) { f[sz] = i; t[sz] = i + 1; w[sz] = 1; sz++; } for (int i = 1; i <= n; i++) { d[i] = 1e9; f[sz] = i; t[sz] = i - 1; w[sz] = 0; sz++; } for (int i = 0; i <= n; i++) { for (int j = 0; j < sz; j++) { if (d[f[j]] + w[j] < d[t[j]]) { d[t[j]] = d[f[j]] + w[j]; } } } for (int j = 0; j < sz; j++) { if (d[f[j]] + w[j] < d[t[j]]) { cout << -1; return 0; } } for (int i = 1; i <= n; i++) { cout << d[i] - d[i - 1] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...