Submission #939328

#TimeUsernameProblemLanguageResultExecution timeMemory
939328PringStray Cat (JOI20_stray)C++14
91 / 100
47 ms17320 KiB
#include <bits/stdc++.h> #include "Anthony.h" using namespace std; const string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) typedef pair<int, int> pii; namespace { const int MXN = 20005; int n, m, A, B; vector<int> eu, ev; vector<int> eid[MXN]; int deg[MXN]; namespace NSA { int d[MXN]; vector<int> tag; void BFS(int sr) { fill(d, d + n, -1); queue<pii> q; q.push(mp(0, sr)); while (q.size()) { auto [dep, id] = q.front(); q.pop(); if (d[id] != -1) continue; d[id] = dep; for (auto &e : eid[id]) { int i = eu[e] ^ ev[e] ^ id; if (d[i] != -1) continue; q.push(mp(dep + 1, i)); } } } vector<int> Mark() { BFS(0); tag.resize(m); FOR(i, 0, m) { if (d[eu[i]] == d[ev[i]]) tag[i] = d[eu[i]] % 3; else tag[i] = min(d[eu[i]], d[ev[i]]) % 3; } return tag; } } namespace NSB { const int mans[6] = {1, 1, 0, 0, 1, 0}; const int mnxt[6] = {2, 2, 0, 0, 2, 0}; vector<int> tag; void BFS(int sr) { queue<pii> q; for (auto &e : eid[sr]) q.push(mp(e, eu[e] ^ ev[e] ^ sr)); while (q.size()) { auto [ep, id] = q.front(); q.pop(); int nxt = (deg[id] == 2 ? (tag[ep] + 1) % 6 : mnxt[tag[ep]]); for (auto &e : eid[id]) { if (e == ep) continue; int i = eu[e] ^ ev[e] ^ id; tag[e] = nxt; q.push(mp(e, i)); } } } vector<int> Mark() { tag.resize(m); BFS(0); FOR(i, 0, m) tag[i] = mans[tag[i]]; return tag; } } } vector<int> Mark(int _n, int _m, int _a, int _b, vector<int> _eu, vector<int> _ev) { n = _n; m = _m; A = _a; B = _b; eu = _eu; ev = _ev; FOR(i, 0, m) { eid[eu[i]].push_back(i); eid[ev[i]].push_back(i); deg[eu[i]]++; deg[ev[i]]++; } return (A >= 3 ? NSA::Mark() : NSB::Mark()); }
#include <bits/stdc++.h> #include "Catherine.h" using namespace std; #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) typedef pair<int, int> pii; namespace { int A, B; namespace NSA { int Move(vector<int> &y) { int a = y[0], b = y[1], c = y[2]; int cnt = (a != 0) + (b != 0) + (c != 0); if (cnt == 1) return (a ? 0 : (b ? 1 : 2)); return (a == 0 ? 1 : (b == 0 ? 2 : 0)); } } namespace NSB { bool confused; int lst; string go; // 110010 bool far() { string t = "110010110010"; FOR(i, 0, 6) if (t.substr(i, 5) == go) return true; return false; } int Move(vector<int> &y) { int deg = y[0] + y[1]; if (lst == -1) { if (deg == 1) { confused = false; return (lst = (y[0] ? 0 : 1)); } if (deg > 2) { confused = false; return (lst = (y[0] == 1 ? 0 : 1)); } if (y[0] == 1) { go = "01"; return (lst = 1); } if (y[0]) { go = "00"; return (lst = 0); } go = "11"; return (lst = 1); } if (confused) { if (deg == 0) { confused = false; return -1; } if (deg > 1) { if (y[0] && y[1]) { confused = false; return (lst = (lst ^ 1)); } } go.push_back(y[0] ? '0' : '1'); if (go.size() == 5) { confused = false; if (far()) return -1; } return (lst = (y[0] ? 0 : 1)); } if (deg > 1) return (lst = (lst ^ 1)); return (lst = (y[0] ? 0 : 1)); } } } void Init(int _a, int _b) { A = _a; B = _b; NSB::confused = true; NSB::lst = -1; } int Move(vector<int> y) { return (A >= 3 ? NSA::Move(y) : NSB::Move(y)); }

Compilation message (stderr)

Anthony.cpp: In function 'void {anonymous}::NSA::BFS(int)':
Anthony.cpp:29:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |                 auto [dep, id] = q.front();
      |                      ^
Anthony.cpp: In function 'void {anonymous}::NSB::BFS(int)':
Anthony.cpp:61:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   61 |                 auto [ep, id] = q.front();
      |                      ^
#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...