Submission #391466

#TimeUsernameProblemLanguageResultExecution timeMemory
391466denkendoemeerStray Cat (JOI20_stray)C++14
100 / 100
62 ms17000 KiB
#include<bits/stdc++.h> #include "Anthony.h" #define ll long long const int inf=1e9; using namespace std; int d[20005],s[6]={0,0,1,0,1,1}; vector<int>g[20005],ans; queue<int>q; void dfs(int nod,int t,vector<int>&u,vector<int>&v) { for(auto it:g[nod]){ int nod2=u[it]^v[it]^nod; if (nod2!=t){ ans[it]=s[d[nod]]; d[nod2]=g[nod2].size()>2?(ans[it]^1)<<1:(d[nod]+1)%6; dfs(nod2,nod,u,v); } } } vector<int> Mark(int n,int m,int a,int b,vector<int>u,vector<int>v) { ans.resize(m); int i; for(i=0;i<m;i++){ g[u[i]].push_back(i); g[v[i]].push_back(i); } d[0]=1; if (a>2){ q.push(0); while(!q.empty()){ int nod=q.front(); q.pop(); for(auto it:g[nod]){ int nod2=u[it]^v[it]^nod; if (d[nod2]==0){ d[nod2]=d[nod]+1; q.push(nod2); } if (d[nod2]==d[nod] || d[nod2]==d[nod]+1) ans[it]=d[nod]%3; } } } else{ dfs(0,-1,u,v); } return ans; }
#include<bits/stdc++.h> #include "Catherine.h" using namespace std; int a,b,pre=-1; int s[6]={0,0,1,0,1,1}; bool ok=0; vector<int>g; void Init(int A,int B) { a=A; b=B; } int Move(vector<int>v) { if (a>2){ if (~pre) v[pre]++; int i; for(i=0;i<3;i++) if (v[i] && v[(i+1)%3]) return pre=i; for(i=0;i<3;i++) if (v[i]) return pre=i; } else{ if (ok){ if (v[0]+v[1]>1) v[pre]++; return pre=(v[0]==1)^1; } if (!~pre){ if (v[0]+v[1]!=2){ ok=1; return pre=(v[0]==1)^1; } pre=(v[0]>0)^1; g.push_back((v[0]>1)^1); g.push_back(pre); return pre; } if (v[0]+v[1]==0){ ok=1; return -1; } if (v[0]+v[1]>1){ ok=1; return !v[pre]?-1:pre^=1; } g.push_back((v[0]==1)^1); if (g.size()==5){ int i; for(i=0;i<6;i++){ ok=1; int j; for(j=0;j<5;j++) ok&=s[(i+j)%6]==g[j]; if (ok) return -1; } ok=1; } return pre=(v[0]==1)^1; } return -2; }
#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...