Submission #871900

#TimeUsernameProblemLanguageResultExecution timeMemory
871900Mr_PhSpeedrun (RMI21_speedrun)C++14
0 / 100
195 ms2616 KiB
#include "speedrun.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; vector<int>path; vector<vector<int>>adj; void dfs1(int node,int parent) { path.push_back(node); if(parent!=-1) { for(int i=0;i<20;i++) { if((1ll<<i)&parent) setHint(node,i+1,1); } } for(auto i:adj[node]) { if(i==parent) continue; dfs1(i,node); } } void assignHints(int subtask, int n, int a[], int b[]) { setHintLen(20); adj.resize(n+1); for(int i=1;i<n;i++) { adj[a[i]].push_back(b[i]); adj[b[i]].push_back(a[i]); } dfs1(1,-1); // for(auto i:path)cout<<i<<" "; // cout<<endl; for(int i=0;i<path.size()-1;i++) { int lol=path[i+1]; for(int j=0;j<10;j++) { if((1ll<<j)&path[i+1]) { setHint(path[i],j+10+1,1); } } } } void dfs(int node,int parent,int start,int n) { //cout<<node<<endl; for(auto i:adj[node]) { if(i==parent)continue; goTo(i); dfs(i,node,start,n); } if(node!=start) goTo(parent); } void speedrun(int subtask, int n, int start) { /* your solution here */ while(start!=1) { int lol=0; for(int i=0;i<10;i++) { if(getHint(i+1)) lol+=(1ll<<i); } // cout<<"HI"<<" "<<lol<<endl; start=lol; goTo(lol); } int curnode=1; while(1) { int lol=0; for(int i=0;i<10;i++) if(getHint(i+11))lol+=(1ll<<i); if(lol==0)return; //cout<<curnode<<endl; while(!goTo(lol)) { int parent=0; // cout<<curnode<<" "<<lol<<" "<<goTo(lol)<<endl; for(int i=0;i<10;i++) { if(getHint(i+11))parent+=(1ll<<i); } goTo(parent); curnode=parent; } goTo(lol); curnode=lol; // if(cnt==5)break; } }

Compilation message (stderr)

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<path.size()-1;i++)
      |                 ~^~~~~~~~~~~~~~
speedrun.cpp:38:13: warning: unused variable 'lol' [-Wunused-variable]
   38 |         int lol=path[i+1];
      |             ^~~
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:73:9: warning: variable 'curnode' set but not used [-Wunused-but-set-variable]
   73 |     int curnode=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...