답안 #306961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306961 2020-09-26T15:18:58 Z giorgikob 기지국 (IOI20_stations) C++14
0 / 100
873 ms 872 KB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 1e3+5;

vector<int>gr[N];

int cnt = 0;
int fix[N];
//int c = 0;

void dfs(int x, vector<int>&v){
    fix[x] = 1;
    for(auto to : gr[x]){
        if(fix[to]) continue;
        dfs(to,v);
    }
    v[x] = cnt; cnt++;
}

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

	//for(int i = 0; i < n; i ++ ) labels[i] = i;

	for(int i = 0; i < u.size(); i++){
        int x = u[i];
        int y = v[i];
        gr[x].pb(y);
        gr[y].pb(x);
	}
    if(k == 1000) cnt = 0;
    dfs(0,labels);
	for(int i = 0; i < n; i++) gr[i].clear(), fix[i] = 0;

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    if(s < t) return c.back();
    int x = t; bool ok = false;
    while(x != 0){
        x = (x-1)/2;
        if(x == s){
            ok = true;
        }
    }
    if(!ok) return c.back();
    for(int i = 0; i < c.size(); i++){
        if(c[i] >= t)
            return c[i];
    }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:32:19: 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++){
      |                 ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i = 0; i < c.size(); i++){
      |                    ~~^~~~~~~~~~
stations.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 537 ms 772 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 475 ms 812 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 549 ms 776 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 873 ms 872 KB Output is correct
2 Incorrect 707 ms 872 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 603 ms 768 KB Wrong query response.
2 Halted 0 ms 0 KB -