Submission #747830

#TimeUsernameProblemLanguageResultExecution timeMemory
747830piOOEStray Cat (JOI20_stray)C++17
20 / 100
48 ms16448 KiB
#include "Anthony.h" #include <bits/stdc++.h> using namespace std; std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) { std::vector<int> X(M, -1); vector<vector<pair<int, int>>> adj(N); for (int i = 0; i < M; ++i) { adj[U[i]].push_back({V[i], i}); adj[V[i]].push_back({U[i], i}); } vector<int> dist(N, -1), par(N), e(N, -1), ord; dist[0] = 0; queue<int> q; q.push(0); while (!q.empty()) { int v = q.front(); q.pop(); ord.push_back(v); for (auto [to, i] : adj[v]) { if (dist[to] == -1) { dist[to] = dist[v] + 1; par[to] = v; e[to] = i; q.push(to); } } } if (B == 0) { for (int i = 0; i < M; ++i) { if (dist[U[i]] > dist[V[i]]) { swap(U[i], V[i]); } X[i] = dist[U[i]] % 3; } } else { for (int i = 1; i < N; ++i) { if (adj[i].size() > 2) { for (auto [to, j] : adj[i]) { X[j] = (dist[i] % 2) ^ (e[i] != j); } } } vector<int> code{0, 1, 0, 0, 1, 1, 1}; vector<int> dp(N, -1); reverse(ord.begin(), ord.end()); for (int x : ord) { if (e[x] == -1 || X[e[x]] != -1) { continue; } dp[x] = (dp[x] + 1) % size(code); X[e[x]] = code[dp[x]]; dp[par[x]] = dp[x]; } } assert(find(X.begin(), X.end(), -1) == X.end()); return X; }
#include "Catherine.h" #include <bits/stdc++.h> using namespace std; namespace { int A, B, e = -1; bool ok = false; vector<int> adj; vector<int> code{0, 1, 0, 0, 1, 1, 1}; bool extendable(vector<int> a) { for (int i = 0; i < size(code); ++i) { bool yay = true; for (int k = 0; k < size(a); ++k) { if (a[k] != code[(i + k) % size(code)]) { yay = false; break; } } if (yay) { return true; } } return false; } } void Init(int A, int B) { ::A = A; ::B = B; } int Move(std::vector<int> y) { if (e != -1) { y[e] += 1; } int deg = accumulate(y.begin(), y.end(), 0); if (B == 0) { int fi = -1, se = -1, cnt = 0; for (int i = 0; i < A; ++i) { if (y[i]) { fi = fi == -1 ? i : fi; se = i; cnt += 1; } } if (fi != 0 || se != 2) { return e = fi; } else { return e = se; } } else { if (size(adj) >= size(code)) { ok = true; } if (deg > 2) { ok = true; for (int i = 0; i < A; ++i) { if (y[i] == 1) { if (i == e) { return -1; } else { return e = i; } } } } else if (deg == 1) { ok = true; for (int i = 0; i < A; ++i) { if (y[i]) { if (i == e) { return -1; } else { return e = i; } } } } else if (ok) { --y[e]; for (int i = 0; i < A; ++i) { if (y[i]) { return e = i; } } } else { int a = -1, b = -1; for (int i = 0; i < A; ++i) { if (y[i]) { a = a == -1 ? i : a; b = i; } } if (e == -1) { adj.push_back(a); adj.push_back(b); return e = b; } int c = a ^ b ^ e; adj.push_back(c); if (extendable(adj)) { return e = c; } else { ok = true; return -1; } } assert(false); } }

Compilation message (stderr)

Catherine.cpp: In function 'bool {anonymous}::extendable(std::vector<int>)':
Catherine.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for (int i = 0; i < size(code); ++i) {
      |                         ~~^~~~~~~~~~~~
Catherine.cpp:17:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |             for (int k = 0; k < size(a); ++k) {
      |                             ~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...