Submission #371072

#TimeUsernameProblemLanguageResultExecution timeMemory
371072chubyxdxdSplit the Attractions (IOI19_split)C++17
18 / 100
123 ms17776 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> G; vector<int> A; vector<int> B; vector<int> C; int vis[100010]; void dfs(int node,int a,int b,int c){ vis[node]=1; B.push_back(node); if(B.size()==b)return; for(auto i:G[node]){ if(vis[i]==-1){ dfs(i,a,b,c); if(B.size()==b)return; } } } void dfs2(int node,int a,int b,int c){ //cout<<node<<endl; if(A.size()<a){ A.push_back(node); } else{ if(B.size()<b){ B.push_back(node); } else{ C.push_back(node); } } vis[node]=1; for(auto i:G[node]){ //cout<<i<<" "; if(vis[i]==-1){ dfs2(i,a,b,c); } } //cout<<endl; } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> ans(n,0); G.assign(n+5,vector<int>()); for(int i=0;i<p.size();i++){ G[p[i]].push_back(q[i]); G[q[i]].push_back(p[i]); } //cout<<a<<endl; /* if(a==1){ if(c<b)swap(c,b); memset(vis,-1,sizeof vis); dfs(0,a,b,c); for(auto i:B){ ans[i]=2; } //cout<<a<<endl; for(int i=0;i<n;i++){ if(ans[i]==0){ if(a>0){ ans[i]=1; a--; continue; } if(c>0){ ans[i]=3; c--; } } } return ans; }*/ int piv=0; for(int i=0;i<n;i++){ vis[i]=-1; if(G[i].size()==1)piv=i; } dfs2(piv,a,b,c); for(auto i:A)ans[i]=1; for(auto i:B)ans[i]=2; for(auto i:C)ans[i]=3; return ans; }

Compilation message (stderr)

split.cpp: In function 'void dfs(int, int, int, int)':
split.cpp:13:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |   if(B.size()==b)return;
      |      ~~~~~~~~^~~
split.cpp:17:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |       if(B.size()==b)return;
      |          ~~~~~~~~^~~
split.cpp: In function 'void dfs2(int, int, int, int)':
split.cpp:23:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |   if(A.size()<a){
      |      ~~~~~~~~^~
split.cpp:27:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     if(B.size()<b){
      |        ~~~~~~~~^~
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:46:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   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...