Submission #1314084

#TimeUsernameProblemLanguageResultExecution timeMemory
1314084kookeudasStray Cat (JOI20_stray)C++20
0 / 100
61 ms12472 KiB
#include <bits/stdc++.h> #include "Anthony.h" #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; using ld = long double; namespace { vector<pair<int,int>> v[20002]; int n,m; int deg[20002] = {0}; int cc[6] = {0,1,1,0,0,1}; vector<int> ret; bool vst[20002] = {0}; pair<int,int> E[20002]; int d[20002]; } void dfs(int node, int b, int c, int lst){ if(deg[node]>=3){ for(pair<int,int> nxt:v[node])if(nxt.first!=b){ ret[nxt.second] = 1-lst; if(lst==1)dfs(nxt.first,node,1,1-lst); else dfs(nxt.first,node,0,1-lst); } return; } for(pair<int,int> nxt:v[node])if(nxt.first!=b){ ret[nxt.second] = cc[c]; dfs(nxt.first,node,(c+1)%6,cc[c]); } } 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(int i=0;i<m;i++){ v[U[i]].push_back({V[i],i}); v[V[i]].push_back({U[i],i}); deg[U[i]]++; deg[V[i]]++; } for(int i=0;i<n;i++)d[i] = 1e9; for(int i=0;i<m;i++)ret.push_back(-1); if(A>=3){ queue<pair<int,int>> q; q.push({0,0}); while(!q.empty()){ pair<int,int> cur = q.front(); q.pop(); if(d[cur.first]!=1e9)continue; d[cur.first] = cur.second; for(pair<int,int> nxt:v[cur.first])q.push({nxt.first,cur.second+1}); } for(int i=0;i<m;i++){ if(d[U[i]]>d[V[i]]){ ret[i] = d[V[i]]%3; } else if(d[U[i]]<d[V[i]]){ ret[i] = d[U[i]]%3; } else{ ret[i] = d[U[i]]%3; } } return ret; } for(pair<int,int> nxt:v[0]){ ret[nxt.second] = 0; dfs(nxt.first,0,1,0); } return ret; }
#include <bits/stdc++.h> #include "Catherine.h" #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; namespace { bool tf=false; int lst = -1; vector<int> cv; int aa; } void Init(int A, int B) { aa = A; tf=false; lst = -1; cv.clear(); } bool ff(vector<int> cv){ if(cv[0]==2 && cv[1]==1 && cv[2]==2 && cv[3]==0)return false; if(cv[0]==1 && cv[1]==2 && cv[2]==0 && cv[3]==2)return false; if(cv[0]==2 && cv[1]==0 && cv[2]==2 && cv[3]==2)return false; if(cv[0]==0 && cv[1]==2 && cv[2]==2 && cv[3]==2)return false; if(cv[0]==2 && cv[1]==2 && cv[2]==2 && cv[3]==1)return false; if(cv[0]==2 && cv[1]==2 && cv[2]==1 && cv[3]==2)return false; return true; } int Move(std::vector<int> y) { if(aa>=3){ if(lst==-1){ if(y[0]>=1 && y[1]>=1){ lst = 0; return 0; } else if(y[1]>=1 && y[2]>=1){ lst = 1; return 1; } else if(y[0]>=1 && y[2]>=1){ lst = 2; return 2; } else if(y[0]>=1){ lst = 0; } else if(y[1]>=1){ lst = 1; } else{ lst = 2; } return lst; } return (lst+2)%3; } if(tf){ assert(lst!=-1); if(y[0]==1 && y[1]==0){ lst = 0; return 0; } else if(y[0]==0 && y[1]==1){ lst = 1; return 1; } y[lst]++; assert(y[lst]!=1); if(y[0]==1){ lst = 0; return 0; } else{ assert(y[1]==1); lst = 1; return 1; } } if(lst==-1){ if(y[0]+y[1]>=3){ if(y[0]==1){ lst = 0; tf=true; return 0; } else{ assert(y[1]==1); lst = 1; tf=true; return 1; } } assert(y[0]+y[1]!=0); if(y[0]+y[1]==1){ if(y[0]==1){ lst = 0; tf=true; return 0; } else{ assert(y[1]==1); lst = 1; tf=true; return 1; } } assert(y[0]+y[1]==2); int c = -1; if(y[0]==2 && y[1]==0){ c = 0; } if(y[0]==0 && y[1]==2)c = 1; else c = 2; cv.push_back(c); if(y[0]>=1){ lst = 0; return 0; } else{ lst = 1; return 1; } } if(y[0]+y[1]>=2){ y[lst]++; assert(y[0]==1 || y[1]==1); if(y[0]==1){ if(lst==0){ tf=true; return -1; } tf=true; lst = 0; return 0; } else{ if(lst==1){ tf=true; return -1; } tf=true; lst = 1; return 1; } } if(y[0]+y[1]==0){ tf=true; return -1; } y[lst]++; int c = -1; if(y[0]==2 && y[1]==0)c = 0; else if(y[0]==0 && y[1]==2)c = 1; else c = 2; cv.push_back(c); if((int)cv.size()==4){ tf=true; if(!ff(cv)){ return -1; } } y[lst]--; if(y[0]>=1){ lst = 0; return 0; } else{ lst = 1; return 1; } }
#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...