Submission #772788

#TimeUsernameProblemLanguageResultExecution timeMemory
772788Abrar_Al_SamitSplit the Attractions (IOI19_split)C++17
0 / 100
47 ms10600 KiB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;

const int nax = 1e5 + 3;

//subtask 2

vector<int>g[nax];
int m;
bool vis[nax];
int a, b, c;

vector<int>stk;
void dfs(int v) {
	if(vis[v]) return;
	stk.push_back(v);
	vis[v] = 1;
	if(stk.size()==min(b, c)) return;

	for(int u : g[v]) {
		dfs(u);
	}
}
vector<int> find_split(int n, int A, int B, int C, 
	vector<int> p, vector<int> q) {
	a = A, b = B, c = C;

	m = p.size();
	for(int i=0; i<m; ++i) {
		g[p[i]].push_back(q[i]);
		g[q[i]].push_back(p[i]);
	}


	dfs(0);

	int cnt = 0;

	vector<int>res(n, 0);
	for(int x : stk) {
		res[x] = b < c ? 2 : 3;
	}
	for(int i=0; i<n; ++i) if(res[i]==0) {
		if(cnt<max(b, c)) {
			++cnt;
			res[i] = b < c ? 3 : 2;
		} else {
			res[i] = 1;
		}
	}
	return res;
}

Compilation message (stderr)

split.cpp: In function 'void dfs(int)':
split.cpp:19:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   19 |  if(stk.size()==min(b, c)) return;
      |     ~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...