Submission #288915

#TimeUsernameProblemLanguageResultExecution timeMemory
288915mohammedehab2002Stray Cat (JOI20_stray)C++17
29 / 100
72 ms16804 KiB
#include "Anthony.h" #include <bits/stdc++.h> using namespace std; namespace { int seq[]={1,0,1,1,0,0},dist[20005]; vector<pair<int,int> > v[20005]; vector<int> ans; } void dfs(int node,int p,int idx,int gp) { int c=(int)v[node].size()-(p!=-1); for (auto u:v[node]) { if (u.first!=p) { if (c==1) { ans[u.second]=seq[idx]; dfs(u.first,node,(idx+1)%6,seq[idx]); } else { ans[u.second]=!gp; dfs(u.first,node,0,!gp); } } } } vector<int> Mark(int n,int m,int A,int B,vector<int> a,vector<int> b) { for (int i=0;i<m;i++) { v[a[i]].push_back({b[i],i}); v[b[i]].push_back({a[i],i}); } ans=vector<int>(m,-1); if (A==2) dfs(0,-1,0,0); else { memset(dist,-1,sizeof(dist)); queue<int> q; q.push(0); dist[0]=0; while (!q.empty()) { int node=q.front(); q.pop(); for (auto u:v[node]) { if (dist[u.first]==-1) { dist[u.first]=dist[node]+1; q.push(u.first); } if (ans[u.second]==-1) ans[u.second]=dist[node]%3; } } } return ans; }
#include "Catherine.h" #include <bits/stdc++.h> using namespace std; namespace { bool f; int l,seq[]={1,0,1,1,0,0}; vector<int> p; } void Init(int A, int B){} int Move(vector<int> y) { if (y.size()>2) { if ((bool)y[0]+(bool)y[1]+(bool)y[2]==1) { for (int i=0;i<3;i++) { if (y[i]) return i; } } for (int i=0;i<3;i++) { if (!y[i]) return (i+1)%3; } } if (!f) { f=1; bool b=(y[0]>y[1]); if (!y[b]) b^=1; if (y[0]+y[1]==2) { if (y[b]==2) p.push_back(b); else p.push_back(!b); p.push_back(b); } return l=b; } if (!y[0] && !y[1]) { p.clear(); return -1; } if (y[0]+y[1]==1) { p.push_back(y[1]); if (p.size()==5) { for (int i=0;i<6;i++) { bool eq=1; for (int j=0;j<5;j++) eq&=(p[j]==seq[(i+j)%6]); if (eq) { p.clear(); return -1; } } } return l=y[1]; } p.clear(); if (!y[l]) return -1; l^=1; return l; }
#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...