# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
331097 | 2020-11-27T10:27:31 Z | evpipis | Restore Array (RMI19_restore) | C++11 | 600 ms | 1004 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; vector<ii> adj[len]; int dis[len], n, m; void add(int a, int b, int c){ adj[a].pb(mp(b, c)); } void bellman(){ for (int i = 1; i <= n; i++) dis[i] = inf; for (int rep = 0; rep < n; rep++) 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; } bool negative(){ for (int u = 0; u <= n; u++) for (auto v: adj[u]) if (dis[u]+v.se < dis[v.fi]) return true; return false; } 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); } bellman(); if (negative()){ printf("-1\n"); return 0; } print(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 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 | 492 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 | 308 ms | 1004 KB | Output is correct |
2 | Correct | 305 ms | 1004 KB | Output is correct |
3 | Correct | 313 ms | 876 KB | Output is correct |
4 | Correct | 319 ms | 1004 KB | Output is correct |
5 | Correct | 596 ms | 1004 KB | Output is correct |
6 | Execution timed out | 610 ms | 1004 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 308 ms | 1004 KB | Output is correct |
2 | Correct | 305 ms | 1004 KB | Output is correct |
3 | Correct | 313 ms | 876 KB | Output is correct |
4 | Correct | 319 ms | 1004 KB | Output is correct |
5 | Correct | 596 ms | 1004 KB | Output is correct |
6 | Execution timed out | 610 ms | 1004 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 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 | 492 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 | 308 ms | 1004 KB | Output is correct |
12 | Correct | 305 ms | 1004 KB | Output is correct |
13 | Correct | 313 ms | 876 KB | Output is correct |
14 | Correct | 319 ms | 1004 KB | Output is correct |
15 | Correct | 596 ms | 1004 KB | Output is correct |
16 | Execution timed out | 610 ms | 1004 KB | Time limit exceeded |