Submission #923256

# Submission time Handle Problem Language Result Execution time Memory
923256 2024-02-07T03:55:54 Z MinhAnhnd Speedrun (RMI21_speedrun) C++14
Compilation error
0 ms 0 KB
#include "speedrun.h"
#include <bits/stdc++.h>
void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
    bool leaf[N+1];
    bool visited[N+1];
    long parent[N+1];
    long first_val[N+1];
    long second_val[N+1];
    stack<long> tovisit;
    setHintLen(20);
    vector<long> adjlist[N+1];
    vector<long> leaves;
    for (int i = 1;i<=N;i++){
        leaf[i] = 1;
        parent[i] = 0;
        visited[i] = 0;
        first_val[i] = -1;
        second_val[i] = -1;
    }

    setHintLen(N);
    for(int i = 1;i<N;i++){
        adjlist[A[i]].push_back(B[i]);
        adjlist[B[i]].push_back(A[i]);
    }
    tovisit.push(1);
    while(!tovisit.empty()){
        long current = tovisit.top();
        tovisit.pop();
        if(visited[current]) continue;
        visited[current]=1;

        for (auto i:adjlist[current]){
            if(!visited[i]){
                leaf[current] = 0;
                parent[i] = current;
                tovisit.push(i);
            }
        }
    }
    for (int i = 1;i<=N;i++){
        if (leaf[i]){
            leaves.push_back(i);
        }
    }
    for (auto green: leaves){

    }

}

void speedrun(int subtask, int N, int start) { /* your solution here */

}

Compilation message

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:9:5: error: 'stack' was not declared in this scope; did you mean 'std::stack'?
    9 |     stack<long> tovisit;
      |     ^~~~~
      |     std::stack
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from speedrun.cpp:2:
/usr/include/c++/10/bits/stl_stack.h:99:11: note: 'std::stack' declared here
   99 |     class stack
      |           ^~~~~
speedrun.cpp:9:11: error: expected primary-expression before 'long'
    9 |     stack<long> tovisit;
      |           ^~~~
speedrun.cpp:11:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   11 |     vector<long> adjlist[N+1];
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from speedrun.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
speedrun.cpp:11:12: error: expected primary-expression before 'long'
   11 |     vector<long> adjlist[N+1];
      |            ^~~~
speedrun.cpp:12:12: error: expected primary-expression before 'long'
   12 |     vector<long> leaves;
      |            ^~~~
speedrun.cpp:23:9: error: 'adjlist' was not declared in this scope
   23 |         adjlist[A[i]].push_back(B[i]);
      |         ^~~~~~~
speedrun.cpp:26:5: error: 'tovisit' was not declared in this scope
   26 |     tovisit.push(1);
      |     ^~~~~~~
speedrun.cpp:33:21: error: 'adjlist' was not declared in this scope
   33 |         for (auto i:adjlist[current]){
      |                     ^~~~~~~
speedrun.cpp:43:13: error: 'leaves' was not declared in this scope
   43 |             leaves.push_back(i);
      |             ^~~~~~
speedrun.cpp:46:22: error: 'leaves' was not declared in this scope
   46 |     for (auto green: leaves){
      |                      ^~~~~~