Submission #498808

# Submission time Handle Problem Language Result Execution time Memory
498808 2021-12-26T11:57:17 Z SlavicG Speedrun (RMI21_speedrun) C++17
Compilation error
0 ms 0 KB
#include "speedrun.h"
#include "bits/stdc++.h"
using namespace std;
 
#define pb push_back
#define sz(a) (int)a.size()
void setHintLen (int l){}
void setHint(int i, int j, bool b){}
int getLength(){}
bool getHint(int j){}
bool goTo(int x){}

void dfsHint(int u, int par, vector<vector<int>>& adj, vector<int>& right_neighbor, vector<int>& parent, vector<int>& left_child){
    parent[u] = par;
    vector<int> nodes;
    for(int v: adj[u]){
        if(v == par)continue;
        dfsHint(v, u, adj, right_neighbor, parent, left_child);
        nodes.pb(v);
    }
    if(sz(nodes))left_child.pb(nodes[0]);
    for(int i = 0;i + 1 < sz(nodes); ++i){
        right_neighbor[nodes[i]] = nodes[i + 1];
    }
}
void assignHints(int subtask , int n, int a[], int b[]){
    setHintLen(30);

    vector<vector<int>> adj(n + 1);
    for(int i = 1;i <= n - 1; ++i){
        adj[a[i]].pb(b[i]);
        adj[b[i]].pb(a[i]);
    }  
    vector<int> right_neighbor(n + 1, 0), parent(n + 1, 0), left_child(n + 1, 0);
    dfsHint(1, 0, adj, right_neighbor, parent, left_child);

    for(int i = 1;i <= n; ++i){
        int idx = 1;
        for(int j = 9;j >= 0; --j){
            if(parent[i] & (1 << j))setHint(i, idx, 1);
            ++idx;
        }
        for(int j = 9;j >= 0; --j){
            if(left_child[i] & (1 << j))setHint(i, idx, 1);
            ++idx;
        }
        for(int j = 9;j >= 0; --j){
            if(right_neighbor[i] & (1 << j))setHint(i, idx, 1);
            ++idx;
        }
    }
}

void dfs(int u, vector<bool>& vis){
    vis[u] = true;
    int lc = 0, rn = 0, par = 0;
    int idx = 1;
    for(int j = 9;j >= 0; --j){
        if(getHint(idx))par += (1 << j);
        ++idx;
    }
    for(int j = 9;j >= 0; --j){
        if(getHint(idx))lc += (1 << j);
        ++idx;
    }
    for(int j = 9;j >= 0; --j){
        if(getHint(idx))rn += (1 << j);
        ++idx;
    }

    if(lc && !vis[lc]){
        goTo(lc);
        dfs(lc, vis);
    }

    if(rn && !vis[rn]){
        goTo(par);
        goTo(rn);
        dfs(rn, vis);
    }
    if(par != 0)goTo(par);
}
void speedrun(int subtask, int n, int start){
    int l = getLength();
    vector<bool> vis(n + 1, false);
    dfs(start, vis);
}

/*
int main(){

}
*/

Compilation message

speedrun.cpp: In function 'int getLength()':
speedrun.cpp:9:17: warning: no return statement in function returning non-void [-Wreturn-type]
    9 | int getLength(){}
      |                 ^
speedrun.cpp: In function 'bool getHint(int)':
speedrun.cpp:10:21: warning: no return statement in function returning non-void [-Wreturn-type]
   10 | bool getHint(int j){}
      |                     ^
speedrun.cpp: In function 'bool goTo(int)':
speedrun.cpp:11:18: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | bool goTo(int x){}
      |                  ^
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:84:9: warning: unused variable 'l' [-Wunused-variable]
   84 |     int l = getLength();
      |         ^
/usr/bin/ld: /tmp/ccMoQkEx.o: in function `setHintLen(int)':
stub.cpp:(.text+0xc0): multiple definition of `setHintLen(int)'; /tmp/ccY3Jx2z.o:speedrun.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccMoQkEx.o: in function `setHint(int, int, bool)':
stub.cpp:(.text+0x150): multiple definition of `setHint(int, int, bool)'; /tmp/ccY3Jx2z.o:speedrun.cpp:(.text+0x10): first defined here
/usr/bin/ld: /tmp/ccMoQkEx.o: in function `getLength()':
stub.cpp:(.text+0x200): multiple definition of `getLength()'; /tmp/ccY3Jx2z.o:speedrun.cpp:(.text.unlikely+0x0): first defined here
/usr/bin/ld: /tmp/ccMoQkEx.o: in function `getHint(int)':
stub.cpp:(.text+0x210): multiple definition of `getHint(int)'; /tmp/ccY3Jx2z.o:speedrun.cpp:(.text.unlikely+0x4): first defined here
/usr/bin/ld: /tmp/ccMoQkEx.o: in function `goTo(int)':
stub.cpp:(.text+0x420): multiple definition of `goTo(int)'; /tmp/ccY3Jx2z.o:speedrun.cpp:(.text.unlikely+0x8): first defined here
collect2: error: ld returned 1 exit status