Submission #1059960

#TimeUsernameProblemLanguageResultExecution timeMemory
1059960UnforgettableplSplit the Attractions (IOI19_split)C++17
18 / 100
56 ms15660 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> res(n); vector<bool> visited(n); vector<vector<int>> adj(n); for(int i=0;i<p.size();i++)adj[p[i]].emplace_back(q[i]); for(int i=0;i<p.size();i++)adj[q[i]].emplace_back(p[i]); vector<int> order; function<void(int)> dfs = [&](int x) { if(visited[x])return; visited[x]=true; order.emplace_back(x); for(int&i:adj[x])dfs(i); }; bool works = false; for(int i=0;i<n;i++)if(adj[i].size()==1) { dfs(i); works = true; break; } if(!works)dfs(0); for(int i=0;i<a;i++)res[order[i]]=1; for(int i=a;i<a+b;i++)res[order[i]]=2; for(int i=a+b;i<a+b+c;i++)res[order[i]]=3; return res; }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:9:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0;i<p.size();i++)adj[p[i]].emplace_back(q[i]);
      |              ~^~~~~~~~~
split.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(int i=0;i<p.size();i++)adj[q[i]].emplace_back(p[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...