Submission #1204652

#TimeUsernameProblemLanguageResultExecution timeMemory
1204652mychecksedadStray Cat (JOI20_stray)C++20
20 / 100
34 ms13896 KiB
#include "Anthony.h" #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; namespace { int FunctionExample(int i, int A) { return i % A; } vi C = {0, 1, 0, 0, 1, 1}; } vector<int> Mark(int n, int m, int A, int B, std::vector<int> U, std::vector<int> V) { vector<int> X(m); vector<vector<pii>> g(n); for(int i = 0; i < m; ++i){ g[U[i]].pb({V[i], i}); g[V[i]].pb({U[i], i}); } vi vis(n + 1); vis[0] = 1; queue<int> q; vi par(n + 1); vi col(n + 1); q.push(0); while(!q.empty()){ int v = q.front(); q.pop(); for(auto [u, idx]: g[v]){ if(!vis[u]){ par[u] = v; q.push(u); if(A >= 3){ col[u] = (col[v] + 1) % min(A, 3); } else{ if(g[v].size() > 2){ col[u] = col[v] ^ 1; // just normal }else{ // chain if(g[u].size() > 2){ // I am not in chain -> return to normal alternate if(col[v] >= 2) col[u] = C[col[v] - 2] ^ 1; else col[u] = col[v] ^ 1; }else{ col[u] = ((col[v] - 2 + 1) % 6) + 1; } } } vis[u] = 1; } } } if(A >= 3){ for(int i = 0; i < n; ++i){ for(auto [u, idx]: g[i]){ if(col[u] == col[i]){ X[idx] = col[u]; }else{ vi v; v.pb(col[i]); v.pb(col[u]); sort(all(v)); if(v[0] != 0){ X[idx] = 1; }else if(v[1] != 1){ X[idx] = 2; }else{ X[idx] = 0; } } } } }else{ for(int i = 0; i < n; ++i){ for(auto [u, idx]: g[i]){ if(u == par[i]){ if(col[i] >= 2) X[idx] = C[col[i] - 2]; else X[idx] = col[i]; } } } } // for(int i = 0 ; i< m; ++i){ // cerr << U[i] << ' ' << V[i] << ' ' << X[i] << '\n'; // } return X; }
/* Author : Mychecksdead */ #include "Catherine.h" #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; namespace { int last_color = -1; int A, B; bool found = false; vi st; vector<vi> right_hash; bool is_right(){ for(auto v: right_hash){ bool ok = true; for(int j = 0; j < 6; ++j){ if(v[j] != st[j]){ ok = false; } } if(ok) return true; } return false; } } // namespace void Init(int A, int B) { ::A = A; ::B = B; vi v = {0, 1, 0, 0, 1, 1}; for(int j = 0; j < 6; ++j){ right_hash.pb(v); v.pb(v[0]); v.erase(v.begin()); } } int Move(std::vector<int> y) { if(A >= 3){ vi v; if(y[0]) v.pb(0); if(y[1]) v.pb(1); if(y[2]) v.pb(2); if(v.size() == 1) return v[0]; if(v[0] != 0) return 1; if(v[1] != 1) return 2; return 0; } vi v = y; // lazyness to change if(last_color == -1){ // beginning if(v[0] + v[1] == 1){ // leaf found = true; return last_color = v[0] > 0 ? 0 : 1; } if(v[0] + v[1] == 2){ // mid chain last_color = v[0] > 0 ? 0 : 1; st.pb(last_color); return last_color; } found = true; // deg(v) >= 3, we know where to go, so found = true return v[0] == 1 ? 0 : 1; } if(v[0] + v[1] == 0){ // hit leaf found = true; return -1; // nice } if(v[0] + v[1] == 1){ // middle of a chain if(found){ return last_color = v[0] > 0 ? 0 : 1; }else{ // check whether we reached the hash if(st.size() == 6){ if(is_right()){ found = true; return last_color = v[0] > 0 ? 0 : 1; // just continue on the right direction }else{ // reverse direction found = true; return -1; } } last_color = v[0] > 0 ? 0 : 1; // nothing for now st.pb(last_color); return last_color; } } // if we hit a deg(v) >= 3, we will see same thing more than once, or we're in the right direction, so keep alternating. if(v[0] == 0){ found = true; last_color = 0; return -1; } if(v[1] == 0){ found = true; last_color = 1; return -1; } found = true; last_color = 1 - last_color; return last_color; }
#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...