Submission #1294662

#TimeUsernameProblemLanguageResultExecution timeMemory
1294662theiuliusWorld Map (IOI25_worldmap)C++17
Compilation error
0 ms0 KiB
// #include "worldmap.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector<int> v[102];
const int K = 102;
int j = 0;
vector<std::vector<int>> ans(K, vector<int> (K, 1));

void dfs(int x, int last){
  ans[0][j] = x;

  for (auto h : v[x]){
    if (last != h){
      j++;
      dfs(h, x);
    }
  }

  ans[0][j] = x;
  if (j >= K){
    j--;
    return;
  }
  j++;
}

std::vector<std::vector<int>> create_map(int N, int M, std::vector<int> a, std::vector<int> b) {
  for (int k = 0; k < M; k++){
    v[a[k]].pb(b[k]);
    v[b[k]].pb(a[k]);
  }

  dfs(1, 0);

  for (int k = 1; k < K; k++){
    for (int j = 0; j < K; j++){
      ans[k][j] = ans[0][j];
    }
  }

  return ans;
}


main(){
  auto v = create_map(4, 3, {1, 1, 3}, {2, 3, 4});
  cout << v[0].size() << endl;
  for (auto h : v){
    for (auto g : h){
      cout << g << " ";
    }
    cout << endl;
  }
}

Compilation message (stderr)

worldmap.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main(){
      | ^~~~
/usr/bin/ld: /tmp/cctVddQH.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccOSbDPr.o:worldmap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status