# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681922 | 2023-01-14T21:54:16 Z | MilosMilutinovic | Tug of War (BOI15_tug) | C++14 | 16 ms | 4604 KB |
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> #include <array> using namespace std; typedef long long ll; const int N = 30333; int n, k; int l[N]; int r[N]; int s[N]; vector<int> g[4 * N]; int ver; int pos; bool was[N]; void addEdge(int v, int u) { g[v].push_back(u); g[u].push_back(v); } void dfs(int v) { if (v < 2 * n) ver++; else pos++; was[v] = true; for (int u : g[v]) if (!was[u]) dfs(u); } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d%d", &n, &k); assert(k >= 0); for (int i = 0; i < 2 * n; i++) { scanf("%d%d%d", &l[i], &r[i], &s[i]); --l[i];--r[i]; addEdge(i, 2 * n + l[i]); addEdge(i, 3 * n + r[i]); } for (int i = 0; i < 2 * n; i++) if (!was[i]) { ver = 0; pos = 0; dfs(i); if (ver > pos) { printf("NO\n"); return 0; } } printf("YES\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 3156 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 3156 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 4604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 3156 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |