Submission #1080022

# Submission time Handle Problem Language Result Execution time Memory
1080022 2024-08-29T06:21:51 Z Jawad_Akbar_JJ Stations (IOI20_stations) C++17
0 / 100
2 ms 940 KB
#include <iostream>
#include <vector>

using namespace std;
const int N1 = 1005;
vector<int> nei[N1];
int d[N1];

vector<int> label(int n, int k, vector<int> u, vector<int> v){
	bool t = 1;
	for (int i=0;i<n-1;i++){
		nei[u[i]].push_back(v[i]);
		nei[v[i]].push_back(u[i]);
		d[u[i]]++;
		d[v[i]]++;
		t &= min(u[i], v[i]) == i / 2;
		t &= max(u[i], v[i]) == i+1;
	}
	vector<int> lab(n, 0);
	if (k == 1e9){
		for (int i=0;i<n-1;i++){
			lab[u[i]] += (1<<v[i]);
			lab[v[i]] += (1<<u[i]);
		}
		lab[0] += 1e8;
		return lab;
	}
	if (t){
		for (int i=0;i<n;i++)
			lab[i] = i+1;
		lab[0] = 1e8;
		return lab;
	}

	int mx = 0, mn = 0;
	for (int i=0;i<n;i++){
		if (d[i] > d[mx])
			mx = i;
		if (d[i] < d[mn])
			mn = i;
	}

	// if (d[mx] <= 2){
	// }

	return lab;

}

int ver;

bool dfs(int u, int s, int t, int p = -1){
	if (u == t)
		return 1;
	for (int i : nei[u]){
		if (i == p)
			continue;
		bool b = dfs(i, s, t, u);
		if (b and u == s)
			ver = i;
		if (b)
			return 1;
	}
	return 0;
}

int find_next_station(int s, int t, vector<int> lab){
	int n = lab.size();
	if (lab[0] > 1e8){
		lab[0] -= 1e8;
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++)
				if ((1<<j) & lab[i])
					nei[i].push_back(j);
		}
		lab[0] += 1e8;
		return lab[ver];
	}
	if (lab[0] == 1e8){
		lab[0] = 1;
		if (lab[s] < lab[t]){
			for (int i=1;i<=30;i++)
				if ((lab[t]>>i) == lab[s])
					return lab[s] * 2 + ((lab[t] & (1<<(i-1))) == 0);
			if (lab[s] / 2 == 1)
				return 1e8;
			return lab[s] / 2;
		}
		else{
			if (lab[s] / 2 == 1)
				return 1e8;
			return lab[s] / 2;
		}
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:95:1: warning: control reaches end of non-void function [-Wreturn-type]
   95 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=100000000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Invalid labels (values out of range). scenario=0, k=1000000, vertex=0, label=100000000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 940 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-2147483644
2 Halted 0 ms 0 KB -