답안 #309417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309417 2020-10-03T13:39:49 Z georgerapeanu 기지국 (IOI20_stations) C++17
0 / 100
3000 ms 2097152 KB
#include "stations.h"
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

vector<int> graph[1005];

int lst;
void dfs(int nod,int tata,int lvl,vector<int> &labels){
    lst++;
    if(lvl == 0){
        labels[nod] = lst;
    }
    for(auto it:graph[nod]){
        if(it == tata){
            continue;
        }
        dfs(it,nod,lvl ^ 1,labels);
    }
    if(lvl == 1){
        labels[nod] = lst;
    }
    lst++;
}

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

    dfs(0,-1,0,labels);
    
    map<int,int> to_norm;

    for(auto it:labels){
        to_norm[it] = 0;
    }

    int lst = 0;

    for(auto &it:to_norm){
        it.second = ++lst;
    }

    for(auto &it:labels){
        it = to_norm[it];
    }

	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
    sort(c.begin(),c.end());
    if(s < c[0]){
        int father = c.back();
        c.pop_back();
        if(t < s){
            return father;
        }
        for(int i = 0;i < (int)c.size();i++){
            if(c[i] >= t){
                return c[i];
            }
        }
        return father;
    }
    else{
        reverse(c.begin(),c.end());
        int father = c.back();
        c.pop_back();
        reverse(c.begin(),c.end());
        if(t > s){
            return father;
        }
        for(int i = (int)c.size() - 1;i >= 0;i--){
            if(c[i] <= t){
                return c[i];
            }
        }
        return father;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3070 ms 2568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1433 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 866 ms 760 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1257 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -