Submission #898118

#TimeUsernameProblemLanguageResultExecution timeMemory
898118PersistentLifeSpeedrun (RMI21_speedrun)C++14
100 / 100
117 ms1876 KiB
#include "speedrun.h" #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pb push_back vector <int> g[1005]; int dfn[1005],par[1005],clk; void dfs0(int u,int fa) { dfn[u]=++clk,par[u]=fa; for(int i=0;i<g[u].size();i++) if(g[u][i]!=fa) dfs0(g[u][i],u); } void assignHints(int subtask, int N, int A[], int B[]) { setHintLen(20); // return; for(int i=1;i<N;i++) g[A[i]].pb(B[i]),g[B[i]].pb(A[i]); dfs0(1,0); for(int i=1;i<=N;i++) { for(int j=0;j<10;j++) setHint(i,j+1,((par[i]&(1<<j))?1:0)); int nxt=0; for(int j=1;j<=N;j++) if(dfn[j]==dfn[i]+1) nxt=j; for(int j=0;j<10;j++) setHint(i,j+11,((nxt&(1<<j))?1:0)); } } int getpar() { int res=0; for(int j=0;j<10;j++) if(getHint(j+1)) res+=(1<<j); return res; } int getnxt() { int res=0; for(int j=0;j<10;j++) if(getHint(j+11)) res+=(1<<j); return res; } int vis[1005]; void speedrun(int subtask, int N, int start) { int L=getLength(); int u=start; vis[u]=1; int cnt=1; while(getpar()) u=getpar(),vis[u]=1,cnt++,goTo(u); int v=-1; while(cnt<N) { if(v==-1) v=getnxt(); // cout<<u<<" "<<v<<"\n"; // system("pause"); if(goTo(v)) u=v,cnt+=(vis[u]^1),vis[u]=1,v=getnxt(); else u=getpar(),goTo(u); } }

Compilation message (stderr)

speedrun.cpp: In function 'void dfs0(int, int)':
speedrun.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0;i<g[u].size();i++) if(g[u][i]!=fa) dfs0(g[u][i],u);
      |              ~^~~~~~~~~~~~
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:44:6: warning: unused variable 'L' [-Wunused-variable]
   44 |  int L=getLength();
      |      ^
#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...