Submission #760657

#TimeUsernameProblemLanguageResultExecution timeMemory
760657Magikarp4000Stray Cat (JOI20_stray)C++17
89 / 100
331 ms524288 KiB
#include "Anthony.h" #include <bits/stdc++.h> using namespace std; #define OPTM ios_base::sync_with_stdio(0); cin.tie(0); #define INF int(1e9+7) #define ln '\n' #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define FOR(i,s,n) for (int i = s; i < n; i++) #define FORR(i,n,s) for (int i = n; i > s; i--) #define FORX(u, arr) for (auto u : arr) #define PB push_back #define in(v,x) (v.find(x) != v.end()) #define F first #define S second #define PII pair<int, int> #define PLL pair<ll, ll> #define UM unordered_map #define US unordered_set #define PQ priority_queue #define ALL(v) v.begin(), v.end() const ll LLINF = 1e18+1; const int pat[] = {1,1,0,1,0,0}; const int MAXN = 2e4+1; int n,m; vector<PII> v[MAXN]; int p[MAXN], pr[MAXN]; vector<int> res; int d[MAXN], a[MAXN]; namespace { void dfs(int s, int pa) { if (s != 0 && v[s].size() >= 3) { int c = res[pr[s]] == 1 ? 0 : 1; FORX(u,v[s]) { if (u.F == pa) continue; res[u.S] = c; } if (res[pr[s]] == -1) res[pr[s]] = 0; } FORX(u,v[s]) { if (u.F == pa) continue; pr[u.F] = s; pr[u.F] = u.S; dfs(u.F,s); } } void dfs1(int s, int pa, int idx) { FORX(u,v[s]) { if (u.F == pa) continue; int nc = idx; if ((s == 0 || v[s].size() == 2) && res[u.S] == -1) { res[u.S] = pat[idx]; nc = (idx+1)%6; } if (v[s].size() >= 3) nc = 0; dfs1(u.F,s,nc); } } void dfs2(int s, int pa, int val) { FORX(u,v[s]) { if (u.F == pa) continue; res[u.S] = val; dfs2(u.F,s,(val+1)%3); } } } // namespace void sub2() { queue<PII> q; FOR(i,0,n) d[i] = INF; d[0] = 0; q.push({0,0}); while (!q.empty()) { int s = q.front().F, val = q.front().S; q.pop(); FORX(u,v[s]) { if (d[s]+1 < d[u.F]) { d[u.F] = d[s]+1; res[u.S] = val; a[u.F] = val; q.push({u.F,(val+1)%3}); } } } FOR(i,1,n) { FORX(u,v[i]) { if (res[u.S] == -1) { res[u.S] = 4; } } } } void sub3() { dfs2(0,-1,0); } void sub7() { dfs(0,-1); dfs1(0,-1,0); } std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) { n = N; m = M; FOR(i,0,m) { v[U[i]].PB({V[i],i}); v[V[i]].PB({U[i],i}); } FOR(i,0,m) res.PB(-1); if (A == 2) sub7(); else if (A == 3) sub3(); else if (A == 4) sub2(); // FOR(i,0,m) cout << res[i] << ' '; // cout << ln; return res; }
#include "Catherine.h" using namespace std; #define OPTM ios_base::sync_with_stdio(0); cin.tie(0); #define INF int(1e9+7) #define ln '\n' #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define FOR(i,s,n) for (int i = s; i < n; i++) #define FORR(i,n,s) for (int i = n; i > s; i--) #define FORX(u, arr) for (auto u : arr) #define PB push_back #define in(v,x) (v.find(x) != v.end()) #define F first #define S second #define PII pair<int, int> #define PLL pair<ll, ll> #define UM unordered_map #define US unordered_set #define PQ priority_queue #define ALL(v) v.begin(), v.end() const ll LLINF = 1e18+1; namespace { int A, B; bool flag = 0; PII start = {-1,-1}, turn = {0,0}; bool done = 0; int pre = -1; int bruh(int x) { if (x != -1) pre = x; return x; } } // namespace void Init(int A, int B) { ::A = A; ::B = B; } int sub7(std::vector<int> y) { int c0 = y[0], c1 = y[1]; if (pre == 0) c0++; else if (pre == 1) c1++; if (c0+c1 == 1) { flag = 1; if (y[0]) return bruh(0); if (y[1]) return bruh(1); return bruh(-1); } if (c0+c1 >= 3) { flag = 1; if (c0 == 1) { if (y[0] == 1) return bruh(0); return bruh(-1); } else if (c1 == 1) { if (y[1] == 1) return bruh(1); return bruh(-1); } } if (flag) return y[0] == 1 ? bruh(0) : bruh(1); if (start == make_pair(-1,-1)) { start.F = (c0 == 2 || c1 == 2) ? 2 : 1; start.S = (c1 == 2) ? 1 : 0; turn.F++; pre = start.S; return bruh(start.S); } bool db = (c0 == 2 || c1 == 2) ? 1 : 0; int val = y[0] == 1 ? 0 : 1; if (start == make_pair(2,0)) { if (turn.F == 2) { flag = 1; return db ? bruh(-1) : bruh(val); } else { turn.F++; return bruh(val); } } else if (start == make_pair(2,1)) { if (turn.F == 2) { flag = 1; return db ? bruh(val) : bruh(-1); } else { turn.F++; return bruh(val); } } else { if (turn.F == 2) { flag = 1; return db ? bruh(val) : bruh(-1); } else if (turn.F == 1) { if (!done) { if (!db) { turn.F++; return bruh(val); } else { done = 1; turn.S++; return bruh(-1); } } else { if (turn.S == 2) { flag = 1; return db ? bruh(-1) : bruh(val); } else { turn.S++; return bruh(val); } } } } } int sub3(std::vector<int> y) { int c[3] = {0,0,0}; FOR(i,0,3) c[i] += y[i]; if (pre != -1) c[pre]++; if (c[0] && c[1]) return bruh(0); if (c[1] && c[2]) return bruh(1); if (c[2] && c[0]) return bruh(2); FOR(i,0,3) if (c[i]) return bruh(i); } int Move(std::vector<int> y) { if (A == 2) return sub7(y); else if (A == 3) return sub3(y); else if (A == 4) return sub3(y); }

Compilation message (stderr)

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