답안 #1080262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080262 2024-08-29T08:25:58 Z KaleemRazaSyed 기지국 (IOI20_stations) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "stations.h"

using namespace std;

const int N = 1000;
vector<int> G[N];
int in[N], out[N];
int emit = 0;

void add_edge(int x, int y)
{
  G[x].push_back(y);
  G[y].push_back(x);
}

void dfs(int v, int p = -1)
{
  in[v] = emit++;
  for(int u : G[v])
    if(u != p)
      dfs(u, v);
  out[v] = emit;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
  /* emit = 0;
  for(int i = 0; i < n; i ++)
    G[i].clear();
  
  for(int i = 0; i < u.size(); i ++)
    add_edge(u[i], v[i]);

  for(int i = 0; i < N; i ++)
    if(G[i].size() == 1)
      {
	dfs(i);
	break;
      }
  */  
  vector<int> l(n);
  for(int i = 0; i < n; i ++)
    {
      l[i] = i; //  * N + out[i] - 1;
    } 
  return l;
}

int find_next_station(int s, int t, vector<int> c)
{
  if(t < x) return x / 2;

  vector<int> path;
  while(t > x)
    path.push_back(t), t /= 2;

  if(t == x) return path.back();
  return x / 2;
    
    
    
  
  // int ins = s / N, outs = s % N + 1;
  // int in_t = t / N, outt = t % N + 1;
  /* if(s < t)
    return s + 1;
  return s - 1;
  */
  /*
  int p = -1;
  for(int i : c)
    {
      
      int ini = i / N, outi = i % N + 1;
      if(ini <= ins && outs <= outi)
	{
	  p = i;
	  continue;
	}
      
      if(ini <= in_t && outt <= outi)
	return i;
    }
  assert(p != -1);
  return p;
  */}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:10: error: 'x' was not declared in this scope
   52 |   if(t < x) return x / 2;
      |          ^
stations.cpp:55:13: error: 'x' was not declared in this scope
   55 |   while(t > x)
      |             ^
stations.cpp:58:11: error: 'x' was not declared in this scope
   58 |   if(t == x) return path.back();
      |           ^
stations.cpp:59:10: error: 'x' was not declared in this scope
   59 |   return x / 2;
      |          ^