답안 #310055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310055 2020-10-05T11:55:45 Z Lemur95 기지국 (IOI20_stations) C++17
0 / 100
2233 ms 2097156 KB
#include <bits/stdc++.h>
#include "stations.h"
#pragma GCC optimize("Ofast")
#define x first
#define y second
#define ld long double
#define ll long long

using namespace std;

vector <int> g[1005];
int nr;

void dfs(int nod, int h, int tata, vector <int> &labels) {
  if(h % 2 == 0)
    labels[nod] = nr++;
  for(auto &fiu : g[nod]) {
    if(fiu != tata)
      dfs(fiu, h + 1, nod, labels);
  }
  if(h % 2)
    labels[nod] = nr++;
}

vector <int> label(int n, int k, vector <int> u, vector <int> v) {
  vector <int> labels(n);
  for(int i = 0; i < n - 1; i++) {
    g[u[i]].push_back(v[i]);
    g[v[i]].push_back(u[i]);
  }
  dfs(0, 0, -1, labels);
  return labels;
}

int find_next_station(int s, int t, vector <int> c) {
  if(s < c[0]) {
    int tmp = s;
    for(auto &i : c) {
      if(tmp < t && t <= i)
        return i;
      tmp = i;
    }
    return c.back();
  }
  for(int i = 0; i < c.size(); i++) {
    if(c[i] <= t && t < (i != c.size() - 1 ? c[i + 1] : s + 1))
      return c[i];
  }
  return c[0];
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i = 0; i < c.size(); i++) {
      |                  ~~^~~~~~~~~~
stations.cpp:46:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     if(c[i] <= t && t < (i != c.size() - 1 ? c[i + 1] : s + 1))
      |                          ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1386 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 906 ms 768 KB Output is correct
2 Runtime error 1162 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2233 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -