Submission #871898

# Submission time Handle Problem Language Result Execution time Memory
871898 2023-11-11T19:50:48 Z Mr_Ph Speedrun (RMI21_speedrun) C++14
0 / 100
1 ms 600 KB
#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);
        }
    }
    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<20;j++)
        {
            if((1ll<<j)&path[i+1])
            {
                setHint(path[i],j+10,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))
                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+10))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+10))parent+=(1ll<<i);
            }
            goTo(parent);
            curnode=parent;
        }
        goTo(lol);
        curnode=lol;
       // if(cnt==5)break;
    }
}

Compilation message

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 time Memory Grader output
1 Incorrect 0 ms 480 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 476 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 484 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 484 KB Invalid bit index for setHint
2 Halted 0 ms 0 KB -