답안 #718546

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718546 2023-04-04T09:58:45 Z lam 게임 (APIO22_game) C++17
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <cstdlib>
#include <vector>
#include "game.h"

namespace {

int read_int() {
  int x;
  if (scanf("%d", &x) != 1) {
    fprintf(stderr, "Error while reading input\n");
    exit(1);
  }
  return x;
}

}  // namespace

#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int n,k;
typedef pair<int,int> ii;
#define ff first
#define ss second
const int maxn = 3e4 + 10;
vector <int> adj[maxn];
bool vis[1010][maxn];
stack<int> st;
bool dau[maxn];
bool ccheck = 0;
void dfs(int id, int x)
{
    vis[id][x] = 1;
    if (x < id) ccheck = 1;
    for (int i:adj[x])
        if (!vis[id][i]) dfs(id,i);
}

void init(int N, int K) {
    n=N; k=K; ccheck=0;
    for (int i=1; i<=n; i++) adj[i].clear();
    for (int i=2; i<=k; i++) adj[i-1].push_back(i);
    for (int i=1; i<=n; i++)
        dfs(i,i);
}

int add_teleporter(int u, int v) {
    u++; v++;
    adj[u].push_back(v);
    for (int i=1; i<=k; i++)
        if (vis[i][u]&&!vis[i][v]) dfs(i,v);
    return ccheck;
}



int main() {
  int N = read_int();
  int M = read_int();
  int K = read_int();
  std::vector<int> u(M), v(M);
  for (int i = 0; i < M; ++i) {
    u[i] = read_int();
    v[i] = read_int();
  }

  init(N, K);
  int i;
  for (i = 0; i < M; ++i) {
    int answer = add_teleporter(u[i], v[i]);
    if (answer != 0 && answer != 1) {
      i = -1;
      break;
    } else if (answer == 1) {
      break;
    }
  }
  printf("%d\n", i);
  return 0;
}

Compilation message

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