# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94120 | 2019-01-16T10:25:07 Z | Kastanda | Tug of War (BOI15_tug) | C++11 | 104 ms | 6520 KB |
#include<bits/stdc++.h> #define pb push_back using namespace std; const int N = 30004, MXN = N * 20; int n, k, L[N], R[N], A[N], C[MXN]; bool M[N * 2]; set < int > Adj[N * 2]; bitset < MXN > B; int Brute() { int nn = n + n; vector < int > T[30]; for (int i = 0; i < (1 << nn); i++) { for (int j = 1; j <= nn; j++) T[j].clear(); for (int j = 0; j < nn; j++) { int id = j + 1; if (i >> j & 1) { T[L[id]].push_back(id); } else { T[R[id]].push_back(id); } } int sum = 0, fail = 0; for (int j = 1; j <= n + n; j++) { if (T[j].size() != 1) {fail = 1; break;} if (j <= n) sum += A[T[j][0]]; else sum -= A[T[j][0]]; } if (fail == 0 && abs(sum) <= k) return 1; } return 0; } int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n + n; i++) scanf("%d%d%d", &L[i], &R[i], &A[i]), R[i] += n; if (Brute()) printf("YES"); else printf("NO"); return (0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 101 ms | 3320 KB | Output is correct |
2 | Correct | 9 ms | 3192 KB | Output is correct |
3 | Correct | 102 ms | 3192 KB | Output is correct |
4 | Correct | 4 ms | 3192 KB | Output is correct |
5 | Correct | 103 ms | 3192 KB | Output is correct |
6 | Correct | 102 ms | 3196 KB | Output is correct |
7 | Correct | 7 ms | 3196 KB | Output is correct |
8 | Correct | 32 ms | 3196 KB | Output is correct |
9 | Correct | 9 ms | 3200 KB | Output is correct |
10 | Correct | 102 ms | 3192 KB | Output is correct |
11 | Correct | 8 ms | 3192 KB | Output is correct |
12 | Correct | 5 ms | 3192 KB | Output is correct |
13 | Correct | 15 ms | 3192 KB | Output is correct |
14 | Correct | 8 ms | 3192 KB | Output is correct |
15 | Correct | 5 ms | 3192 KB | Output is correct |
16 | Correct | 101 ms | 3292 KB | Output is correct |
17 | Correct | 16 ms | 3240 KB | Output is correct |
18 | Correct | 8 ms | 3192 KB | Output is correct |
19 | Correct | 6 ms | 3192 KB | Output is correct |
20 | Correct | 18 ms | 3232 KB | Output is correct |
21 | Correct | 99 ms | 3192 KB | Output is correct |
22 | Correct | 8 ms | 3164 KB | Output is correct |
23 | Correct | 104 ms | 3216 KB | Output is correct |
24 | Correct | 7 ms | 3192 KB | Output is correct |
25 | Correct | 100 ms | 3192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 101 ms | 3320 KB | Output is correct |
2 | Correct | 9 ms | 3192 KB | Output is correct |
3 | Correct | 102 ms | 3192 KB | Output is correct |
4 | Correct | 4 ms | 3192 KB | Output is correct |
5 | Correct | 103 ms | 3192 KB | Output is correct |
6 | Correct | 102 ms | 3196 KB | Output is correct |
7 | Correct | 7 ms | 3196 KB | Output is correct |
8 | Correct | 32 ms | 3196 KB | Output is correct |
9 | Correct | 9 ms | 3200 KB | Output is correct |
10 | Correct | 102 ms | 3192 KB | Output is correct |
11 | Correct | 8 ms | 3192 KB | Output is correct |
12 | Correct | 5 ms | 3192 KB | Output is correct |
13 | Correct | 15 ms | 3192 KB | Output is correct |
14 | Correct | 8 ms | 3192 KB | Output is correct |
15 | Correct | 5 ms | 3192 KB | Output is correct |
16 | Correct | 101 ms | 3292 KB | Output is correct |
17 | Correct | 16 ms | 3240 KB | Output is correct |
18 | Correct | 8 ms | 3192 KB | Output is correct |
19 | Correct | 6 ms | 3192 KB | Output is correct |
20 | Correct | 18 ms | 3232 KB | Output is correct |
21 | Correct | 99 ms | 3192 KB | Output is correct |
22 | Correct | 8 ms | 3164 KB | Output is correct |
23 | Correct | 104 ms | 3216 KB | Output is correct |
24 | Correct | 7 ms | 3192 KB | Output is correct |
25 | Correct | 100 ms | 3192 KB | Output is correct |
26 | Runtime error | 9 ms | 6264 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
27 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 12 ms | 6520 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 101 ms | 3320 KB | Output is correct |
2 | Correct | 9 ms | 3192 KB | Output is correct |
3 | Correct | 102 ms | 3192 KB | Output is correct |
4 | Correct | 4 ms | 3192 KB | Output is correct |
5 | Correct | 103 ms | 3192 KB | Output is correct |
6 | Correct | 102 ms | 3196 KB | Output is correct |
7 | Correct | 7 ms | 3196 KB | Output is correct |
8 | Correct | 32 ms | 3196 KB | Output is correct |
9 | Correct | 9 ms | 3200 KB | Output is correct |
10 | Correct | 102 ms | 3192 KB | Output is correct |
11 | Correct | 8 ms | 3192 KB | Output is correct |
12 | Correct | 5 ms | 3192 KB | Output is correct |
13 | Correct | 15 ms | 3192 KB | Output is correct |
14 | Correct | 8 ms | 3192 KB | Output is correct |
15 | Correct | 5 ms | 3192 KB | Output is correct |
16 | Correct | 101 ms | 3292 KB | Output is correct |
17 | Correct | 16 ms | 3240 KB | Output is correct |
18 | Correct | 8 ms | 3192 KB | Output is correct |
19 | Correct | 6 ms | 3192 KB | Output is correct |
20 | Correct | 18 ms | 3232 KB | Output is correct |
21 | Correct | 99 ms | 3192 KB | Output is correct |
22 | Correct | 8 ms | 3164 KB | Output is correct |
23 | Correct | 104 ms | 3216 KB | Output is correct |
24 | Correct | 7 ms | 3192 KB | Output is correct |
25 | Correct | 100 ms | 3192 KB | Output is correct |
26 | Runtime error | 9 ms | 6264 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
27 | Halted | 0 ms | 0 KB | - |