답안 #411747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411747 2021-05-25T20:33:32 Z AKaan37 기지국 (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long lo; 
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 1005;
const lo mod = 1000000007;

int sayac=0;
vector<int> vec[li],vv;
int dp[li];

inline void dfs(int node,int ata){
	vv[node]=++sayac;
	int flagg=0;
	for(auto go:vec[node]){
		if(go==ata)continue;
		flagg=1;
		dfs(go,node);
	}
	if(flagg)sayac+=1000-1;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> vvv) {
	std::vector<int> labels(n);
	for(int i=0;i<n-1;i++){
		vec[u[i]].pb(vvv[i]);
		vec[vvv[i]].pb(u[i]);
	}
	int ind=-1;
	for(int i=0;i<n;i++){
		vv.pb(1);
		if((int)vec[i].size()>2)ind=i;
	}
	if(ind==-1){
		for(int i=0;i<n;i++){
			if(vec[i].size()==1)ind=i;
		}
	}
	dfs(ind,-1);
	for (int i = 0; i < n; i++) {
		//~ cout<<vv[i]<<endl;
		labels[i] = vv[i];
	}
	return labels;
}

inline int f(int sira,int hedef){
	int cevv=0;
	if(sira>hedef)return 0;
	if(sira==hedef)return 1;
	if(~dp[sira])return dp[sira];
	cevv=max(cevv,f(sira*2+1,hedef));
	cevv=max(cevv,f(sira*2+2,hedef));
	return dp[sira]=cevv;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if((int)c.size()==1)return c[0];
	if(abs(t-s)>=1000)return c[0];
	if((int)c.size()==2)return c[1];
	int siz=(int)c.size();
	for(int i=0;i<siz-1;i++){
		if(c[i+1]>t)return c[i];
	}
	return c[siz-1];
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2199 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3088 ms 392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2367 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3158 ms 1299688 KB Time limit exceeded
2 Halted 0 ms 0 KB -