답안 #305424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305424 2020-09-23T03:46:02 Z ivan24 기지국 (IOI20_stations) C++14
0 / 100
1394 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

using ll = int;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define F first
#define S second

class Solver{
private:
    ll k,n,ctr;
    vvi adjList;
    vi dfs_num, sz, label;
    void DFS(ll v){
        for (auto u: adjList[v]){
            if (dfs_num[u] == -1){
                DFS(u);
            }
        }
        dfs_num[v] = ctr++;
        label[v] = dfs_num[v]*1000+sz[v];
    }
public:
    Solver(ll k, ll n, vi u, vi v): k(k), n(n), adjList(n,vi()), dfs_num(n,-1), sz(n,1), label(n){
        for (ll i = 0; u.size() > i; i++){
            adjList[u[i]].push_back(v[i]);
            adjList[v[i]].push_back(u[i]);
        }
        ctr = 0;
        DFS(0);
    }
    vi get_labels(){
        return label;
    }
};

vi label(int n, int k, vi u, vi v) {
	Solver mySolver(n,k,u,v);
	return mySolver.get_labels();
}

int find_next_station(int s, int t, std::vector<int> c) {
	ii v = ii(s/1000,s%1000);
	ii e = ii(t/1000,t%1000);
	vii children(c.size());
	for (ll i = 0; c.size() > i; i++){
        children[i] = ii(c[i]/1000,c[i]%1000);
	}
	sort(children.begin(),children.end());
	for (ll i = 1; children.size() > i; i++){
        if (children[i].F+children[i].S > e.F && e.F >= children[i].F){
            return children[i].F*1000+children[i].S;
        }
	}
	return children[0].F*1000+children[0].S;
}

Compilation message

stations.cpp: In constructor 'Solver::Solver(ll, ll, vi, vi)':
stations.cpp:30:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   30 |         for (ll i = 0; u.size() > i; i++){
      |                        ~~~~~~~~~^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:51:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   51 |  for (ll i = 0; c.size() > i; i++){
      |                 ~~~~~~~~~^~~
stations.cpp:55:33: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   55 |  for (ll i = 1; children.size() > i; i++){
      |                 ~~~~~~~~~~~~~~~~^~~
stations.cpp:48:5: warning: variable 'v' set but not used [-Wunused-but-set-variable]
   48 |  ii v = ii(s/1000,s%1000);
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1394 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1280 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1256 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -