Submission #1031168

#TimeUsernameProblemLanguageResultExecution timeMemory
1031168Marco_EscandonSplit the Attractions (IOI19_split)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef int ll; #define x first #define y second vector<ll> cad[100005]; vector<ll> sts,sol; ll aux=0;pair<ll,ll> st={1e9,1e9}; ll dfs(ll node){ if(sts[node]!=0) return 0; sts[node]=1; for(auto i:cad[node]) sts[node]+=dfs(i); if(sts[node]>=aux) st=min(st,{sts[node],node}); return sts[node]; } void fillst(ll node, ll c, ll cnt) { sol[node]=c;cnt--; queue<ll>q;q.push(node); while(!q.empty()) { for(auto i:cad[q.front()]) { if(sts[i]<sts[q.front()]&&sol[i]==0&&cnt>0) { sol[i]=c; cnt--; q.push(i); } } q.pop(); } } void fill2(ll n, pair<ll,ll> a, pair<ll,ll> b) { for(int i=0; i<n; i++) { if(sol[i]==0||sol[i]==5) { ll cnt=0; sol[i]=5; queue<ll>q;q.push(i); while(!q.empty()) { for(auto i:cad[q.front()]) { if(sol[i]==0) { sol[i]=5; cnt++; q.push(i); } } q.pop(); } if(cnt>=a.x&&a.x>0) { sol[i]=a.y;a.x--; queue<ll>q;q.push(i); while(!q.empty()) { for(auto i:cad[q.front()]) { if(sol[i]==5&&a.x>0) { sol[i]=a.y; a.x--; q.push(i); } } q.pop(); } } else if(b.y>0) { sol[i]=b.y;b.x--; queue<ll>q;q.push(i); while(!q.empty()) { for(auto i:cad[q.front()]) { if(sol[i]==5&&b.x>0) { sol[i]=b.y; b.x--; q.push(i); } } q.pop(); } } } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { sts.assign(n,0);sol.assign(n,0); pair<ll,ll> temp[]={{a,1},{b,2},{c,3}}; sort(temp,temp+3); for(int i=0; i<p.size(); i++) { cad[p[i]].push_back(q[i]); cad[q[i]].push_back(p[i]); } aux=temp[0].x;dfs(0); if(n-st.x<temp[0].x) return sol; if(st.x>n-st.x) swap(temp[0],temp[1]); fillst(st.y,temp[0].y,temp[0].x); fill2(n, temp[1],temp[2]); return sol; } int main() { int n, m, a, b, c; assert(5 == scanf("%d%d%d%d%d", &n, &m, &a, &b, &c)); vector<int> p(m), q(m); for (int i=0; i<m; i++) assert(2 == scanf("%d%d", &p[i], &q[i])); fclose(stdin); vector<int> result = find_split(n, a, b, c, p, q); for (int i=0; i<(int)result.size(); i++) printf("%s%d", ((i>0)?" ":""), result[i]); printf("\n"); fclose(stdout); return 0; }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:100:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |  for(int i=0; i<p.size(); i++)
      |               ~^~~~~~~~~
/usr/bin/ld: /tmp/cc4N6cIS.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccS8EMPU.o:split.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status