Submission #298415

#TimeUsernameProblemLanguageResultExecution timeMemory
298415emil_physmathSplit the Attractions (IOI19_split)C++17
7 / 100
91 ms13104 KiB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 100'005;

vector<int> nei[maxN];
bool used[maxN];

void DFSGet(int v, vector<int>& a)
{
    used[v] = true;
    a.push_back(v);
    for (int to: nei[v])
        if (!used[to])
            DFSGet(to, a);
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
    for (int i = 0; i < p.size(); ++i) {
        int u = p[i], v = q[i];
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    bool sub1 = true;
    for (int i = 0; i < n; ++i)
        if (nei[i].size() > 2)
            sub1 = false;
    if (sub1) {
        vector<int> x;
        int root = 0;
        for (int i = 0; i < n; ++i)
            if (nei[i].size() == 1)
                root = i;
        DFSGet(root, x);
        vector<int> res(n, 3);
        for (int i = 0; i < a; ++i)
            res[x[i]] = 1;
        for (int i = a; i < a + b; ++i)
            res[x[i]] = 2;
        return res;
    }
	vector<int> res;
	if (n == 9) {
		res = {1, 1, 3, 1, 2, 2, 3, 1, 3};
	} else {
		res = {0, 0, 0, 0, 0, 0};
	}
	return res;
}

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < p.size(); ++i) {
      |                     ~~^~~~~~~~~~
#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...