답안 #1080038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080038 2024-08-29T06:30:24 Z KaleemRazaSyed 기지국 (IOI20_stations) C++17
10 / 100
649 ms 776 KB
#include<bits/stdc++.h>
#include "stations.h"

using namespace std;

const int N = 1005;
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)
{
  // cerr << v << endl;
  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)
{
  for(int i = 0; i < n; i ++)
    G[i].clear();
  
  for(int i = 0; i < u.size(); i ++)
    add_edge(u[i], v[i]);

  dfs(0);
  
  vector<int> l(n);
  for(int i = 0; i < n; i ++)
    l[i] = in[i] * N + out[i];
  return l;
}

int find_next_station(int s, int t, vector<int> c)
{
  int ins = s / N, outs = s % N;
  int in_t = t / N, outt = t % N;
  
  int p = -1;
  for(int i : c)
    {
      
      int ini = i / N, outi = i % N;
      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 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int i = 0; i < u.size(); i ++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6040
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1517
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=392, label=1000974
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 577 ms 684 KB Output is correct
2 Correct 500 ms 684 KB Output is correct
3 Correct 424 ms 684 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 3 ms 764 KB Output is correct
6 Correct 0 ms 760 KB Output is correct
7 Correct 417 ms 684 KB Output is correct
8 Correct 649 ms 684 KB Output is correct
9 Correct 450 ms 684 KB Output is correct
10 Correct 415 ms 684 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 3 ms 772 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 310 ms 684 KB Output is correct
17 Correct 294 ms 684 KB Output is correct
18 Correct 336 ms 684 KB Output is correct
19 Correct 345 ms 684 KB Output is correct
20 Correct 354 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 395 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -