## Submission #1041287

# Submission time Handle Problem Language Result Execution time Memory
1041287 2024-08-01T20:10:22 Z VMaksimoski008 Restore Array (RMI19_restore) C++17
100 / 100
96 ms 856 KB
```#include <bits/stdc++.h>
using namespace std;

int main() {
int n, m;
cin >> n >> m;

vector<array<int, 3> > edges;
for(int i=0; i<m; i++) {
int l, r, k, val;
cin >> l >> r >> k >> val; l++; r++;
if(val == 0) edges.push_back({ l - 1, r, r - l + 1 - k});
else edges.push_back({ r, l - 1, -(r - l + 1) + k - 1 });
}

for(int i=1; i<=n; i++) edges.push_back({ i-1, i, 1 });
for(int i=1; i<=n; i++) edges.push_back({ i, i-1, 0 });

vector<int> dist(n+1, 1e9); dist[0] = 0;
for(int i=1; i<=n; i++)
for(auto &[u, v, w] : edges) dist[v] = min(dist[v], dist[u] + w);

for(auto &[u, v, w] : edges) {
if(dist[v] > dist[u] + w) {
cout << -1 << '\n';
return 0;
}
}

for(int i=1; i<=n; i++) cout << (dist[i] > dist[i-1]) << " ";
return 0;
}```

#### Subtask #1 7.0 / 7.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct

#### Subtask #2 13.0 / 13.0

# Verdict Execution time Memory Grader output
1 Correct 82 ms 796 KB Output is correct
2 Correct 85 ms 792 KB Output is correct
3 Correct 88 ms 804 KB Output is correct
4 Correct 84 ms 796 KB Output is correct
5 Correct 86 ms 796 KB Output is correct
6 Correct 82 ms 792 KB Output is correct

#### Subtask #3 25.0 / 25.0

# Verdict Execution time Memory Grader output
1 Correct 82 ms 796 KB Output is correct
2 Correct 85 ms 792 KB Output is correct
3 Correct 88 ms 804 KB Output is correct
4 Correct 84 ms 796 KB Output is correct
5 Correct 86 ms 796 KB Output is correct
6 Correct 82 ms 792 KB Output is correct
7 Correct 95 ms 792 KB Output is correct
8 Correct 89 ms 796 KB Output is correct
9 Correct 87 ms 796 KB Output is correct
10 Correct 85 ms 792 KB Output is correct
11 Correct 85 ms 792 KB Output is correct
12 Correct 86 ms 796 KB Output is correct
13 Correct 84 ms 796 KB Output is correct
14 Correct 91 ms 796 KB Output is correct
15 Correct 91 ms 792 KB Output is correct
16 Correct 90 ms 792 KB Output is correct

#### Subtask #4 55.0 / 55.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 82 ms 796 KB Output is correct
12 Correct 85 ms 792 KB Output is correct
13 Correct 88 ms 804 KB Output is correct
14 Correct 84 ms 796 KB Output is correct
15 Correct 86 ms 796 KB Output is correct
16 Correct 82 ms 792 KB Output is correct
17 Correct 95 ms 792 KB Output is correct
18 Correct 89 ms 796 KB Output is correct
19 Correct 87 ms 796 KB Output is correct
20 Correct 85 ms 792 KB Output is correct
21 Correct 85 ms 792 KB Output is correct
22 Correct 86 ms 796 KB Output is correct
23 Correct 84 ms 796 KB Output is correct
24 Correct 91 ms 796 KB Output is correct
25 Correct 91 ms 792 KB Output is correct
26 Correct 90 ms 792 KB Output is correct
27 Correct 87 ms 856 KB Output is correct
28 Correct 87 ms 796 KB Output is correct
29 Correct 85 ms 796 KB Output is correct
30 Correct 87 ms 796 KB Output is correct
31 Correct 93 ms 796 KB Output is correct
32 Correct 96 ms 796 KB Output is correct
33 Correct 90 ms 792 KB Output is correct
34 Correct 84 ms 792 KB Output is correct
35 Correct 94 ms 792 KB Output is correct
36 Correct 86 ms 792 KB Output is correct