답안 #982808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982808 2024-05-14T18:24:36 Z alo_54 게임 (APIO22_game) C++17
컴파일 오류
0 ms 0 KB
//#include "game.h"
#include <bits/stdc++.h>
using namespace std;

struct Nodo
{
  vector <int> ady;
  bool special = false;

};

vector <Nodo> g;
vector <bool> vis;
bool acPos = 0;
int K;

int dfs(int node)
{
 // cout<<"call "<<node<<endl;

  vis[node] = true;

  int resp = 0;
  
  for (auto i : g[node].ady)
  {
    //cout<<"check "<<i<<endl;
    if (!vis[i])
    {
      //cout<<"check "<<i<<endl;
      resp = dfs(i);
    }else
    {
      if (g[i].special)
      {
        //cout<<"si"<<endl;
        acPos = 1;
        resp = 1;
      }
      
      
    }
  }

  //cout<<"no"<<endl;

  return resp;


}

void init(int n, int k) 
{
  vis.resize(n);
  g.resize(n);

  K = k;
  
  for (int i = 0; i < k; i++)
  {
    g[i].special = true;

    if (k != k-1)
    {
      g[i].ady.push_back(i+1);
    }
    
    
  }
  
}

int add_teleporter(int u, int v) 
{
  fill(vis.begin(), vis.end(), false);
  g[u].ady.push_back(v);

  int resp = acPos;

  for (int i = 0; i < K; i++)
  {
    resp = dfs(i);

    if (resp == 1)
    {
      acPos = true;
      break;
    }
    
  }

  if (acPos)
  {
    resp = true;
  }
  
  
  return resp;
}

int main()
{
  int n, k, m; cin>>n>>k>>m;

  init(n, k);

  while (m--)
  {
    int u, v; cin>>u>>v;

    int resp = add_teleporter(u, v);
    cout<<resp<<endl;
  }
  
  
}

Compilation message

/usr/bin/ld: /tmp/cc2apvAt.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cceMATyt.o:game.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status