답안 #431920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431920 2021-06-17T17:20:30 Z Ozy 기지국 (IOI20_stations) C++17
0 / 100
2382 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 1000

lli act,ini,fin;
vector<lli> hijos[MAX+2];
vector<int> res;

void DFS (lli pos, lli padre, lli prof) {
    if (prof%2 == 0) res[pos] = act++;
    for (auto h : hijos[pos]) {
        if (h == padre) continue;
        DFS(h,pos,prof+1);
    }
    if (prof%2 == 1) res[pos] = act++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {

    //res.resize(n, -1);
    res = vector<int> (n,0);

	rep(i,0,n-2) {
        hijos[u[i]].push_back(v[i]);
        hijos[v[i]].push_back(u[i]);
	}

	act = 0;
	DFS(0,0,0);

	return res;
}

int find_next_station(int s, int t, std::vector<int> c) {

    if (c.size() == 1) return c[0];

    if (s == 0) rep (i,0,c.size()-1) if (t <= c[i]) return c[i];

    if (s < c[0]) {
        ini = s;
        fin = c[c.size()-2];

        if (t < ini || t > fin) return c[c.size()-1];

        rep (i,0,c.size()-2) if (t <= c[i]) return c[i];
    }
    else {
        ini = c[1];
        fin = s;

        if (t < ini || t > fin) return c[0];
        repa (i,c.size()-1,1) if (t >= c[i]) return c[i];
    }

    return c[0];
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
stations.cpp:45:17: note: in expansion of macro 'rep'
   45 |     if (s == 0) rep (i,0,c.size()-1) if (t <= c[i]) return c[i];
      |                 ^~~
stations.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
      |                                       ^
stations.cpp:53:9: note: in expansion of macro 'rep'
   53 |         rep (i,0,c.size()-2) if (t <= c[i]) return c[i];
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1242 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 584 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1417 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 870 ms 488 KB Output is correct
2 Runtime error 1105 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2382 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -