Submission #145434

#TimeUsernameProblemLanguageResultExecution timeMemory
145434JovanK26Split the Attractions (IOI19_split)C++14
0 / 100
14 ms11260 KiB
#include "split.h" #include<bits/stdc++.h> using namespace std; vector< vector<int> > v(200001); bool cmp(pair<vector<int>,int> i,pair<vector<int>,int> j) { i.first.size()<j.first.size(); } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> rez(n); for(int i=0;i<p.size();i++) { v[p[i]].push_back(q[i]); v[q[i]].push_back(p[i]); } if(a==1) { if(b>c)swap(b,c); vector< pair<vector<int>,int> >g(200001); for(int i=0;i<n;i++) { g[i]=make_pair(v[i],i); } bool vis[n]; queue<int> q; for(int i=0;i<n;i++) { rez[i]=0; vis[i]=0; } sort(g.begin(),g.begin()+n,cmp); int start=g[0].second; vis[start]=1; rez[start]=1; int br=0; int node=g[n-1].second; q.push(node); vis[node]=1; while(!q.empty()) { int cur=q.front(); q.pop(); rez[cur]=2; br++; if(br==b)break; for(int i=0;i<v[node].size();i++) { if(!vis[v[node][i]]) { vis[v[node][i]]=1; q.push(v[node][i]); } } } for(int i=0;i<n;i++) { if(rez[i]==0)rez[i]=3; } } return rez; }

Compilation message (stderr)

split.cpp: In function 'bool cmp(std::pair<std::vector<int>, int>, std::pair<std::vector<int>, int>)':
split.cpp:7:19: warning: value computed is not used [-Wunused-value]
     i.first.size()<j.first.size();
     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
split.cpp:8:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:13:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<p.size();i++)
              ~^~~~~~~~~
split.cpp:48:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<v[node].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...