Submission #288957

#TimeUsernameProblemLanguageResultExecution timeMemory
288957phillipSplit the Attractions (IOI19_split)C++14
18 / 100
144 ms16248 KiB
#include "split.h" #include <bits/stdc++.h> #define ll long long #define fast cin.tie(0);cout.tie(0); #define order ios::sync_with_stdio(0);ios_base::sync_with_stdio(0); #define pb push_back using namespace std; int rv[3],num[3]; vector<int>v[200009]; int vis[200009],col[200009]; void dfs(int x,int par,int id) { if(num[id]==0)id++; if(vis[x])return; vis[x]=1; col[x]=rv[id]; num[id]--; for(int i=0;i<v[x].size();i++) { int y=v[x][i]; if(y==par)continue; dfs(y,x,id); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> res; num[0]=a; num[1]=b; num[2]=c; int mx=max(a,max(b,c)); int mn=min(a,min(b,c)); for(int i=0;i<3;i++) { if(num[i]==mx) { //cout<<i<<" "; rv[2]=i+1; if(num[(i+1)%3]==mn){rv[0]=(i+1)%3+1;rv[1]=(i+2)%3+1;} else {rv[1]=(i+1)%3+1;rv[0]=(i+2)%3+1;} break; } } sort(num,num+3); for(int i=0;i<p.size();i++) { v[p[i]].pb(q[i]); v[q[i]].pb(p[i]); } int rt=0; for(int i=0;i<n;i++) { if(v[i].size()==1) { rt=i; break; } } dfs(rt,rt,0); for(int i=0;i<n;i++)res.push_back(col[i]); //cout<<rv[0]<<" "<<rv[1]<<" "<<rv[2]<<"\n"; return res; }

Compilation message (stderr)

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