Submission #1310938

#TimeUsernameProblemLanguageResultExecution timeMemory
1310938moha1111Stations (IOI20_stations)C++20
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
#include "stations.h"

using namespace std;

int[] label(int n, int k, int[] u, int[] v)
{
    vector<int> graph[n + 5];
    for(int i = 0 ; i < n - 1 ; i++)
    {
        graph[u[i]].push_back(v[i]);
        graph[v[i]].push_back(u[i]);
    }
    int la[n] = {};
    int cur;
    for(int i = 0 ; i < n ; i++)
    {
        if(graph[i].size() == 1)
        {
            la[i] = 1 , cur = i;
            break;
        }
    }
    for(int i = 2 ; i < n ; i++)
    {
        int n1 = graph[cur][0];
        if(la[n1] == 0)
            la[n1] = i , cur = n1;
        
        else
            la[graph[cur][1]] = i , cur = la[graph[cur][1]];
    }
    if(la[graph[cur][0]] == 0)
        la[graph[cur][0]] = n;
    
    else
        la[graph[cur][1]] = n;
    
    return la;
}

int find_next_station(int s, int t, int[] c)
{
    if(s < t)
        return c[0];
    
    else
        return c[1];
}

Compilation message (stderr)

stations.cpp:6:4: error: structured binding declaration cannot have type 'int'
    6 | int[] label(int n, int k, int[] u, int[] v)
      |    ^~
stations.cpp:6:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
stations.cpp:6:4: error: empty structured binding declaration
stations.cpp:6:7: error: expected initializer before 'label'
    6 | int[] label(int n, int k, int[] u, int[] v)
      |       ^~~~~
stations.cpp:42:43: error: expected ',' or '...' before 'c'
   42 | int find_next_station(int s, int t, int[] c)
      |                                           ^
stations.cpp: In function 'int find_next_station(int, int, int*)':
stations.cpp:45:16: error: 'c' was not declared in this scope
   45 |         return c[0];
      |                ^
stations.cpp:48:16: error: 'c' was not declared in this scope
   48 |         return c[1];
      |                ^