답안 #354386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
354386 2021-01-21T20:12:34 Z doowey 기지국 (IOI20_stations) C++14
0 / 100
1025 ms 1068 KB
#include <bits/stdc++.h>
#include "stations.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

const int N = 1005;
vector<int> T[N];

vector<int> sol;
int ti;

void dfs(int u, int pp, int bit){
    if(bit == 0){
        sol[u]=ti;
        ti++;
    }
    for(auto x : T[u]){
        if(x==pp) continue;
        dfs(x,u,(bit^1));
    }
    if(bit == 1){
        sol[u]=ti;
        ti++;
    }
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	ti = 0;
	sol.clear();
	sol.resize(n);
	for(int i = 0 ; i < n; i ++ ){
        T[i].clear();
	}
	for(int i = 0 ; i < u.size(); i ++ ){
        T[u[i]].push_back(v[i]);
        T[v[i]].push_back(u[i]);
	}
	dfs(0,-1,0);
	return sol;
}

int find_next_station(int s, int t, vector<int> c) {
    for(auto x : c){
        if(x == t) return x;
    }
	bool is = true;
	for(auto x : c){
        if(s < x) is = false;
	}
	if(is){ // s is tout
        sort(c.begin(), c.end());
        if(t <= c[0] || t >= s){
            return c[0];
        }
        c.push_back(s);
        for(int i = 0 ; i + 1 < c.size(); i ++ ){
            if(t >= c[i] && t <= c[i + 1]){
                return i;
            }
        }
	}
    else{
        sort(c.begin(), c.end());
        if(t < s) return c.back();
        if(t >= c.back()) return c.back();
        if(t >= s && t <= c[0]){
            return c[0];
        }
        for(int i = 1; i < c.size(); i ++ ){
            if(c[i - 1] < t && t <= c[i]){
                return c[i];
            }
        }
    }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0 ; i < u.size(); i ++ ){
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for(int i = 0 ; i + 1 < c.size(); i ++ ){
      |                         ~~~~~~^~~~~~~~~~
stations.cpp:76:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         for(int i = 1; i < c.size(); i ++ ){
      |                        ~~^~~~~~~~~~
stations.cpp:82:1: warning: control reaches end of non-void function [-Wreturn-type]
   82 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 503 ms 992 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 469 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 553 ms 1068 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1025 ms 736 KB Output is correct
2 Correct 747 ms 952 KB Output is correct
3 Correct 650 ms 952 KB Output is correct
4 Correct 3 ms 824 KB Output is correct
5 Incorrect 4 ms 736 KB Wrong query response.
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 577 ms 1008 KB Wrong query response.
2 Halted 0 ms 0 KB -