Submission #879419

#TimeUsernameProblemLanguageResultExecution timeMemory
879419andrei_boacaSplit the Attractions (IOI19_split)C++17
Compilation error
0 ms0 KiB
#include "split.h" #include <bits/stdc++.h> //#include "grader.cpp" //#pragma GCC optimize ("Ofast") //#pragma GCC optimize ("fast-math") //#pragma GCC optimize ("unroll-loops") using namespace std; typedef pair<int,int> pii; mt19937 rng(chrono::steady_clock().now().time_since_epoch().count()); int n,m; int take[5],ord[5]; vector<int> sol; bool byval(int a,int b) { return take[a]<take[b]; } vector<int> kids[100005],edges[100005]; vector<int> dsu[100005]; int comp[100005]; vector<pii> g; vector<int> linie; int par[100005]; bool use[100005]; vector<int> nodes; int nr[100005]; int niv[100005],nivmin[100005]; int part[100005]; void dfs(int nod) { nr[nod]=1; use[nod]=1; nivmin[nod]=niv[nod]; for(int i:edges[nod]) { if(i==par[nod]) continue; if(!use[i]) { niv[i]=niv[nod]+1; dfs(i); kids[nod].push_back(i); nr[nod]+=nr[i]; nivmin[nod]=min(nivmin[nod],nivmin[i]); } else nivmin[nod]=min(nivmin[nod],niv[i]); } } vector<int> find_split(int N, int A, int B, int C, vector<int> p, vector<int> q) { n=N; take[1]=A; take[2]=B; take[3]=C; ord[1]=1; ord[2]=2; ord[3]=3; sort(ord+1,ord+4,byval); sol.resize(n); m=p.size(); for(int i=0;i<n;i++) { par[i]=-1; comp[i]=i+1; dsu[i+1].push_back(i); } for(int i=0;i<p.size();i++) { int a,b; a=p[i]; b=q[i]; edges[a].push_back(b); edges[b].push_back(a); } niv[0]=1; dfs(0); for(int v=0;v<n;v++) if(valid(v)) { vector<int> rebeli; int lg1=nr[v],lg2=n-nr[v]; for(int i=0;i<kids[v].size()&&!good(lg1,lg2);i++) { int u=kids[v][i]; if(nivmin[u]<nivmin[v]&&lg1-nr[u]>=take[ord[1]]) { lg1-=nr[u]; rebeli.push_back(u); lg2+=nr[u]; } } if(good(lg1,lg2)) { part[v]=1; for(int i:rebeli) put(i,2); if(par[v]!=-1) put(par[v],2); put(v,1); } } }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:67:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i=0;i<p.size();i++)
      |                 ~^~~~~~~~~
split.cpp:78:12: error: 'valid' was not declared in this scope
   78 |         if(valid(v))
      |            ^~~~~
split.cpp:82:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |             for(int i=0;i<kids[v].size()&&!good(lg1,lg2);i++)
      |                         ~^~~~~~~~~~~~~~~
split.cpp:82:44: error: 'good' was not declared in this scope
   82 |             for(int i=0;i<kids[v].size()&&!good(lg1,lg2);i++)
      |                                            ^~~~
split.cpp:92:16: error: 'good' was not declared in this scope
   92 |             if(good(lg1,lg2))
      |                ^~~~
split.cpp:96:21: error: 'put' was not declared in this scope; did you mean 'putw'?
   96 |                     put(i,2);
      |                     ^~~
      |                     putw
split.cpp:98:21: error: 'put' was not declared in this scope; did you mean 'putw'?
   98 |                     put(par[v],2);
      |                     ^~~
      |                     putw
split.cpp:99:17: error: 'put' was not declared in this scope; did you mean 'putw'?
   99 |                 put(v,1);
      |                 ^~~
      |                 putw
split.cpp:103:1: warning: no return statement in function returning non-void [-Wreturn-type]
  103 | }
      | ^