Submission #910970

#TimeUsernameProblemLanguageResultExecution timeMemory
910970gawr_guraStray Cat (JOI20_stray)C++17
20 / 100
60 ms16820 KiB
#include "Anthony.h" #include <bits/stdc++.h> using namespace std; namespace std { template <int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Dimension must be positive"); template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {} }; template <typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : std::vector<T>(n, val) {} }; /* Example Vec<4, int64_t> f(n, k, 2, 2); // = f[n][k][2][2]; Vec<2, int> adj(n); // graph */ template <class Fun> class y_combinator_result { Fun fun_; public: template <class T> explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {} template <class... Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); } }; template <class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); } /* Example auto fun = y_combinator([&](auto self, int x) -> void { self(x + 1); }); */ } // namespace std std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) { vector<vector<pair<int, int>>> adj(N); for (int i = 0; i < M; i++) adj[U[i]].emplace_back(V[i], i); for (int i = 0; i < M; i++) adj[V[i]].emplace_back(U[i], i); vector<int> depth(M, -1); vector<int> d(N, -1); if (A == 4) A = 3; if (A == 3) { queue<int> q; q.emplace(0); d[0] = 0; while (q.size()) { int u = q.front(); q.pop(); for (auto &&[v, i] : adj[u]) { if (d[v] == -1) { d[v] = d[u] + 1; depth[i] = d[u]; q.emplace(v); } } } vector<int> ans(M); for (int i = 0; i < M; i++) { if (depth[i] == -1) { if (d[U[i]] == d[V[i]]) { ans[i] = d[U[i]] % 3; } else { ans[i] = min(d[U[i]], d[V[i]]) % 3; } } else { ans[i] = depth[i] % 3; } } return ans; } else { vector<int> base({0, 1, 1, 0, 0, 1}); vector<int> deg(N); for (int i = 0; i < M; i++) deg[U[i]]++, deg[V[i]]++; queue<int> q; q.emplace(0); d[0] = 0; vector<int> par(N); vector<int> ans(M); while (q.size()) { int u = q.front(); q.pop(); for (auto &&[v, i] : adj[u]) { if (d[v] == -1) { d[v] = d[u] + 1; if (u == 0 || deg[u] == 2) { ans[i] = (666666 - d[u]) % 6; } else { ans[i] = par[u] ^ 1; } par[v] = ans[i]; q.emplace(v); } } } for (int i = 0; i < M; i++) ans[i] = base[ans[i]]; return ans; } }
#include "Catherine.h" #include <bits/stdc++.h> using namespace std; namespace std { template <int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Dimension must be positive"); template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {} }; template <typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : std::vector<T>(n, val) {} }; /* Example Vec<4, int64_t> f(n, k, 2, 2); // = f[n][k][2][2]; Vec<2, int> adj(n); // graph */ template <class Fun> class y_combinator_result { Fun fun_; public: template <class T> explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {} template <class... Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); } }; template <class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); } /* Example auto fun = y_combinator([&](auto self, int x) -> void { self(x + 1); }); */ } // namespace std namespace { int A, B; stack<int> st; int last = -1; vector<int> base({0, 1, 1, 0, 0, 1}); vector<int> possible; bool good = 0; } // namespace void Init(int A, int B) { ::A = A; ::A = min(::A, 3); ::B = B; possible.resize(6); iota(possible.begin(), possible.end(), 0); } int Move(std::vector<int> y) { if (A == 3) { int cnt = 0; for (int i = 0; i < A; i++) { cnt += y[i] > 0; } if (cnt == 1) { for (int i = 0; i < A; i++) { if (y[i] > 0) return i; } } else { for (int i = 0; i < A; i++) { if (y[i] > 0 && y[(i + 1) % A] > 0) return i; } } } else { if (last != -1) y[last]++; int cnt = 0; int xam = 0; for (int i = 0; i < A; i++) { xam = max(xam, y[i]); cnt += y[i] > 0; } int nxt = -1; if (xam > 1 && cnt > 1) { good = 1; for (int i = 0; i < A; i++) { if (y[i] == 1) { int ans = last == i ? -1 : i; last = i; return ans; } } } else { if (cnt == 1) { for (int i = 0; i < A; i++) { if (y[i] == 1) { int ans = last == i ? -1 : i; last = i; return ans; } } for (int i = 0; i < A; i++) { if (y[i] > 0) nxt = i; } if (good) return nxt; goto check; } else { if (good) { last ^= 1; return last; } else { goto check; } } } check:; if (nxt == -1) { nxt = last == -1 ? 1 : (cnt == 1 ? last : (last ^ 1)); } vector<int> npo; for (int i : possible) { if (base[(i + 1) % 6] == nxt) npo.emplace_back((i + 1) % 6); } possible.swap(npo); if (possible.size() == 0) { good = 1; return -1; } else { last = nxt; return nxt; } } }

Compilation message (stderr)

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:144:1: warning: control reaches end of non-void function [-Wreturn-type]
  144 | }
      | ^
#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...