답안 #1080249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080249 2024-08-29T08:19:35 Z KaleemRazaSyed 기지국 (IOI20_stations) C++17
5 / 100
693 ms 1272 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] = in[i]; //  * N + out[i] - 1;
    } 
  return l;
}

int find_next_station(int s, int t, vector<int> c)
{
  // 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 '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 Correct 320 ms 684 KB Output is correct
2 Correct 277 ms 712 KB Output is correct
3 Correct 693 ms 684 KB Output is correct
4 Correct 454 ms 684 KB Output is correct
5 Correct 415 ms 684 KB Output is correct
6 Correct 316 ms 684 KB Output is correct
7 Correct 319 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 776 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 289 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 337 ms 684 KB Output is correct
2 Correct 303 ms 684 KB Output is correct
3 Correct 641 ms 684 KB Output is correct
4 Correct 443 ms 684 KB Output is correct
5 Correct 358 ms 684 KB Output is correct
6 Correct 323 ms 684 KB Output is correct
7 Correct 294 ms 684 KB Output is correct
8 Correct 2 ms 1272 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
11 Incorrect 395 ms 796 KB Wrong query response.
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 617 ms 684 KB Output is correct
2 Correct 476 ms 844 KB Output is correct
3 Correct 398 ms 684 KB Output is correct
4 Correct 1 ms 760 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 1 ms 776 KB Output is correct
7 Incorrect 412 ms 684 KB Wrong query response.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 379 ms 688 KB Output is correct
2 Correct 294 ms 684 KB Output is correct
3 Correct 609 ms 684 KB Output is correct
4 Correct 436 ms 684 KB Output is correct
5 Correct 409 ms 684 KB Output is correct
6 Correct 276 ms 684 KB Output is correct
7 Correct 326 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Incorrect 304 ms 860 KB Wrong query response.
12 Halted 0 ms 0 KB -