Submission #1135287

#TimeUsernameProblemLanguageResultExecution timeMemory
1135287vibeduckSplit the Attractions (IOI19_split)C++20
Compilation error
0 ms0 KiB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

const int mxn = 1e5 + 5;
vi adj[mxn]; int deg[mxn]; vi ans; int cur = 0;
int a1, b1, c1;

void dfs(int node, int prev, int i) {
    ans[node] = i;
    cur++;
    //cout << node << " " << i << " " << cur << '\n';
    if (i == 1) {if (cur == a) {i++; cur = 0;}}
    else if (i == 2) {if (cur == b) {i++; cur = 0;}}
    else if (i == 3) {if (cur == c) {return;}}
    for (auto neighbour : adj[node]) {
        if (neighbour == prev) continue;
        dfs(neighbour, node, i);
        return;
    }
}

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	a1 = a; b1 = b; c1 = c;
	int m = p.size();
	ans.resize(n);
    for (int i = 0; i < m; i++) {
		adj[p[i]].push_back(q[i]);
		adj[q[i]].push_back(p[i]);
		deg[p[i]]++; deg[q[i]]++;
	}
    if (m == n) dfs(0, -1, 1);
	else {
		int x = 0;
		for (int i = 1; i < n; i++) if (deg[i] < deg[x]) x = i;
		dfs(x, -1, 1);
	}
    return ans;
}

Compilation message (stderr)

split.cpp: In function 'void dfs(int, int, int)':
split.cpp:30:29: error: 'a' was not declared in this scope
   30 |     if (i == 1) {if (cur == a) {i++; cur = 0;}}
      |                             ^
split.cpp:31:34: error: 'b' was not declared in this scope
   31 |     else if (i == 2) {if (cur == b) {i++; cur = 0;}}
      |                                  ^
split.cpp:32:34: error: 'c' was not declared in this scope
   32 |     else if (i == 3) {if (cur == c) {return;}}
      |                                  ^