Submission #161738

#TimeUsernameProblemLanguageResultExecution timeMemory
161738andrewSplit the Attractions (IOI19_split)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "split.h" #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> using namespace std; typedef long long ll; typedef long double ld; const ll MAXN = 1123456; const ll N = 2e5; vector <int> v[MAXN]; int p[MAXN], kol[MAXN]; int get(int x){ if(x != p[x])p[x] = get(p[x]); return p[x]; } void unite(int a, int b){ kol[a] += kol[b]; kol[b] = 0; p[b] = a; } vector<int> find_split(int n, int a, int b, int c, vector<int> P, vector<int> q) { int m = p.size(), mx = 0; for(int i = 0; i < m; i++){ v[P[i]].push_back(q[i]); v[q[i]].push_back(P[i]); mx = max(mx, (int)v[P[i]].size()); mx = max(mx, (int)v[q[i]].size()); } vector <int> res(n); if(mx < 3){ int F = 0, Last = 0; for(int i = 0; i < n; i++)if(v[i].size() == 1)F = i; int step = 1; vector <int> cnt(3); cnt[0] = a; cnt[1] = b; cnt[2] = c; for(int i = 0; i < n; i++){ if(i){ int New = 0; for(auto j : v[F])if(j != Last)New = j; Last = F; F = New; } while(!cnt[step - 1])step++; --cnt[step - 1]; res[F] = step; } return res; }else if(a == 1){ queue <int> Q; vector <bool> f(n); int start = 0; for(int i = 0; i < n; i++)if(v[i].size() == 1)start = i; for(int i = 0; i < n; i++)p[i] = i; for(int i = 0; i < m; i++)if(P[i] != start && q[i] != start){ if(get(P[i]) != get(q[i]))unite(get(P[i]), get(q[i])); } int mx = *max_element(kol, kol + n); if(mx >= b){ int pos = start; kol[start] = 0; for(int i = 0; i < n; i++)if(kol[i] > kol[pos])pos = i; f[start] = 1; for(int i = 0; i < n; i++){ if(P[i] == start){ if(Q.empty()){ f[q[i]] = 1; Q.push(q[i]); } } if(q[i] == start){ if(Q.empty()){ f[P[i]] = 1; Q.push(P[i]); } } } while(!q.empty()){ int x = q.front(); q.pop(); if(!b)break; b--; res[x] = 2; for(auto to : v[x])if(!f[to]){ f[to] = 1; q.push(to); } } res[start] = 1; for(auto &i : res)if(!i)i = 3; }else if(mx >= c){ int pos = start; kol[start] = 0; for(int i = 0; i < n; i++)if(kol[i] > kol[pos])pos = i; f[start] = 1; for(int i = 0; i < n; i++){ if(P[i] == start){ if(Q.empty()){ f[q[i]] = 1; Q.push(q[i]); } } if(q[i] == start){ if(Q.empty()){ f[P[i]] = 1; Q.push(P[i]); } } } while(!q.empty()){ int x = q.front(); q.pop(); if(!c)break; c--; res[x] = 3; for(auto to : v[x])if(!f[to]){ f[to] = 1; q.push(to); } } res[start] = 1; for(auto &i : res)if(!i)i = 2; }else return res; }else{ return res; } 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:32:15: error: request for member 'size' in 'p', which is of non-class type 'int [1123456]'
     int m = p.size(), mx = 0;
               ^~~~
split.cpp:37:9: error: 'mx' was not declared in this scope
         mx = max(mx, (int)v[P[i]].size());
         ^~
split.cpp:37:9: note: suggested alternative: 'm'
         mx = max(mx, (int)v[P[i]].size());
         ^~
         m
split.cpp:43:8: error: 'mx' was not declared in this scope
     if(mx < 3){
        ^~
split.cpp:43:8: note: suggested alternative: 'm'
     if(mx < 3){
        ^~
        m
split.cpp:97:19: error: 'class std::vector<int>' has no member named 'pop'
                 q.pop();
                   ^~~
split.cpp:103:23: error: 'class std::vector<int>' has no member named 'push'
                     q.push(to);
                       ^~~~
split.cpp:129:19: error: 'class std::vector<int>' has no member named 'pop'
                 q.pop();
                   ^~~
split.cpp:135:23: error: 'class std::vector<int>' has no member named 'push'
                     q.push(to);
                       ^~~~