# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
312797 | BeanZ | Restore Array (RMI19_restore) | C++14 | 379 ms | 1404 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 5005;
struct viet{
ll u, v, c;
};
ll d[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("A.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) d[i] = i;
vector<viet> E;
for (int i = 1; i <= m; i++){
ll l, r, k, v;
cin >> l >> r >> k >> v;
l++;
r++;
if (v == 1){
E.push_back({r, l - 1, -(r - l + 1 - k + 1)});
} else {
// S(r) - S(l - 1) <= (r - l + 1 - k)
E.push_back({l - 1, r, r - l + 1 - k});
}
}
for (int i = 1; i <= n; i++){
E.push_back({i - 1, i, 1});
E.push_back({i, i - 1, 0});
}
ll x;
for (int i = 1; i <= n; i++){
x = -1;
for (auto j : E){
if (d[j.v] > (d[j.u] + j.c)){
d[j.v] = d[j.u] + j.c;
x = j.v;
}
}
}
if (x != -1) cout << -1;
else {
for (int i = 1; i <= n; i++){
//cout << d[i] << " ";
if (d[i] > d[i - 1]) cout << 1 << " ";
else cout << 0 << " ";
}
}
}
/*
*/
Compilation message (stderr)
# | 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... |