# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
331101 | 2020-11-27T10:41:30 Z | evpipis | Restore Array (RMI19_restore) | C++11 | 600 ms | 892 KB |
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<int, int> ii; const int len = 5005, inf = 1e9; int dis[len], n, m; vector<ii> adj[len]; void add(int a, int b, int c){ adj[a].pb(mp(b, c)); } bool bellman(){ for (int i = 1; i <= n; i++) dis[i] = inf; int rep = 0; while (rep <= n){ bool upd = false; for (int u = 0; u <= n; u++) for (auto v: adj[u]) if (dis[u]+v.se < dis[v.fi]) dis[v.fi] = dis[u]+v.se, upd = true; if (!upd) break; rep++; } return (rep <= n); } void print(){ for (int i = n; i >= 1; i--) dis[i] = 1-(dis[i]-dis[i-1]); for (int i = 1; i <= n; i++) printf("%d ", dis[i]); printf("\n"); } int main(){ scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++){ add(i-1, i, 1); add(i, i-1, 0); } for (int i = 0; i < m; i++){ int l, r, k, v; scanf("%d %d %d %d", &l, &r, &k, &v); l++, r++; if (v == 0) add(r, l-1, -k); else add(l-1, r, k-1); } if (!bellman()){ printf("-1\n"); return 0; } print(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 620 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 512 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 748 KB | Output is correct |
2 | Correct | 6 ms | 748 KB | Output is correct |
3 | Correct | 6 ms | 748 KB | Output is correct |
4 | Correct | 8 ms | 748 KB | Output is correct |
5 | Execution timed out | 662 ms | 892 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 748 KB | Output is correct |
2 | Correct | 6 ms | 748 KB | Output is correct |
3 | Correct | 6 ms | 748 KB | Output is correct |
4 | Correct | 8 ms | 748 KB | Output is correct |
5 | Execution timed out | 662 ms | 892 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 620 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 512 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 6 ms | 748 KB | Output is correct |
12 | Correct | 6 ms | 748 KB | Output is correct |
13 | Correct | 6 ms | 748 KB | Output is correct |
14 | Correct | 8 ms | 748 KB | Output is correct |
15 | Execution timed out | 662 ms | 892 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |