Submission #910851

# Submission time Handle Problem Language Result Execution time Memory
910851 2024-01-18T08:30:29 Z dragusanu_rares Speedrun (RMI21_speedrun) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "speedrun.h"
using namespace std;
vector<vector<int>> adj;
int visited[1005];
int parent[1005];
int nxt[1005];
int n,ult_nod=1;
int hint(int nod){
    int poz=1;
    while(parent[nod]>0){
        setHint(nod, poz, parent[nod]&1);
        parent[nod]/=2;
        poz++;
    }
    poz=11;
    while(nxt[nod]>0){
        setHint(nod, poz, nxt[nod]&1);
        nxt[nod]>>=1;
        poz++;
    }
    return;
}
void dfs(int nod){
    for(int i=0;i<adj[nod].size();i++){
        if(!visited[adj[nod][i]]){
            visited[adj[nod][i]]=1;
            nxt[ult_nod]=adj[nod][i];
            ult_nod=adj[nod][i];
            parent[adj[nod][i]]=nod;
            dfs(adj[nod][i]);
        }
    }
    return;
}
void assignHints (int subtask , int N, int a[], int b[]){
    n=N;
    setHintLen(20);
    adj.resize(n+5);
    for(int i=1;i<n;i++){
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }
    ult_nod=1;
    visited[1]=1;
    dfs(1);
    nxt[ult_nod]=0;
    for(int i=1;i<=n;i++){
        hint(i);
    }
    return;
}
void speedrun(int subtask , int N, int nod ){
    int nr;
    while(nod!=1){
        nr=0;
        for(int i=10;i>=1;i--){
            nr=nr*2+getHint(i);
        }
        nod=nr;
        goTo(nr);
    }
    int nxt=1;
    while(1){
        if(nxt==nod){
            nr=0;
            for(int j=20;j>=11;j--){
                nr=nr*2+getHint(j);
            }
            nxt=nr;
            if(nxt==0)return;
        }
        if(goTo(nxt)){
            nod=nxt;
        }
        else{
            nr=0;
            for(int j=10;j>=1;j--){
                nr=nr*2+getHint(j);
            }
            nod=nr;
            goTo(nr);
        }
    }
    return;
}

Compilation message

speedrun.cpp: In function 'int hint(int)':
speedrun.cpp:22:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   22 |     return;
      |     ^~~~~~
speedrun.cpp: In function 'void dfs(int)':
speedrun.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<adj[nod].size();i++){
      |                 ~^~~~~~~~~~~~~~~~