Submission #859126

# Submission time Handle Problem Language Result Execution time Memory
859126 2023-10-09T19:08:16 Z Vanio Speedrun (RMI21_speedrun) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "speedrun.h"
using namespace std;

int n,f[1001],pr;
vector<int> v[1001];

void encode(int p, int k, int indx){
    int i=indx;
    while(k>0){
        setHint(p,i,k%2);
        k/=2;
        i++;
    }
}

dfsen(int k, int par){
    pr=k;
    if(v[k].size()==0){f[k]=2; return;}
    else{
        f[k]=1;
        if(f[pr]==2){
            encode(pr,k,1);
            encode(pr,par,11);
        }
        encode(k,par,1);
        encode(k,v[k][0],11);
        for(int i=0;i<v[k].size();i++){
            if(f[v[k][i]]==0) dfsen(v[k][i],k);
        }
    }
}

void assignHints(int subtask, int N, int a[], int b[]){
    n=N;
    int i;
    for(i=1;i<n;i++){
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    dfsen(1,0);
}


int decode(int indx){
    int s=0,t=512,i;
    for(i=indx;i>indx-10;i--){
        s+=getHint(i)*t;
        t/=2;
    }
    return s;
}

void dfssr(int k,int par){
    if(par!=decode(10)){
        v[decode(20)].push_back(decode(10));
        return;
    }
    v[k].push_back(decode(20));
    for(int i=0;i<v[k].size();i++){
        goTo(v[k][i]);
        dfssr(v[k][i]);
    }
}

void speedrun(int subtask, int N, int start){
    n=N;
    int i,t;
    if(decode(20)==0){
        for(i=1;i<=n;i++){
            if(goTo(i)) break;
        }
    }
    while(t=decode(10)) goTo(t);
    dfssr(1,0);
}

Compilation message

speedrun.cpp:17:1: error: ISO C++ forbids declaration of 'dfsen' with no type [-fpermissive]
   17 | dfsen(int k, int par){
      | ^~~~~
speedrun.cpp: In function 'int dfsen(int, int)':
speedrun.cpp:19:32: error: return-statement with no value, in function returning 'int' [-fpermissive]
   19 |     if(v[k].size()==0){f[k]=2; return;}
      |                                ^~~~~~
speedrun.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i=0;i<v[k].size();i++){
      |                     ~^~~~~~~~~~~~
speedrun.cpp: In function 'void dfssr(int, int)':
speedrun.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int i=0;i<v[k].size();i++){
      |                 ~^~~~~~~~~~~~
speedrun.cpp:62:22: error: too few arguments to function 'void dfssr(int, int)'
   62 |         dfssr(v[k][i]);
      |                      ^
speedrun.cpp:54:6: note: declared here
   54 | void dfssr(int k,int par){
      |      ^~~~~
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:74:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   74 |     while(t=decode(10)) goTo(t);
      |           ~^~~~~~~~~~~
speedrun.cpp: In function 'int dfsen(int, int)':
speedrun.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
   32 | }
      | ^