답안 #1078461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078461 2024-08-27T17:45:37 Z Trumling 기지국 (IOI20_stations) C++14
10 / 100
634 ms 776 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()

vector<vector<ll>>g;
vector<int> Labels;

void dfs(int start,int pre)
{
	Labels[start]=(1<<start);
	for(auto x:g[start])
		if(x!=pre)
		{
			dfs(x,start);
			Labels[start]|=Labels[x];
		}
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	
	
	g.assign(n,vector<ll>());
	Labels.assign(n,0);
	for (int i = 0; i < n-1; i++) {
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
	}
	dfs(0,0);
	for(int i=0;i<n;i++)
		Labels[i]+=i*256;
	

	return Labels;
}

int find_next_station(int s, int t, vector<int> c) {
	
	ll S=s/256;
	ll T=t/256;

	ll par;
	vector<ll>v;
	for(auto x:c)
	{
		if((1<<S)&x)
			par=x;

		if((1<<T)&x)	
			v.pb(x);
	}

	if(S==0)
		return v[0];

	if(v.size()<=1)
		return par;
	
	return v[0] - par + v[1];

}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:66:10: warning: 'par' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |   return par;
      |          ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1023
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 572 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=-1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=0, label=-1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 634 ms 684 KB Output is correct
2 Correct 472 ms 684 KB Output is correct
3 Correct 406 ms 684 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 1 ms 776 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 389 ms 772 KB Output is correct
8 Correct 605 ms 684 KB Output is correct
9 Correct 495 ms 684 KB Output is correct
10 Correct 391 ms 684 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 5 ms 764 KB Output is correct
13 Correct 3 ms 776 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 768 KB Output is correct
16 Correct 343 ms 688 KB Output is correct
17 Correct 345 ms 684 KB Output is correct
18 Correct 344 ms 684 KB Output is correct
19 Correct 369 ms 684 KB Output is correct
20 Correct 326 ms 696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 600 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=0, label=-1
2 Halted 0 ms 0 KB -