Submission #294987

#TimeUsernameProblemLanguageResultExecution timeMemory
294987theStaticMindSplit the Attractions (IOI19_split)C++14
18 / 100
128 ms12024 KiB
#include<bits/stdc++.h> #include "split.h" using namespace std; vector<int> ans; vector<int> adj[100000]; void greedy(int x, int& rem, int v){ if(!rem) return; ans[x] = v; rem--; for(auto y : adj[x]){ if(ans[y]) continue; greedy(y, rem, v); } } vector<int> find_split(int n, int a, int b, int c, vector<int> u, vector<int> v) { ans = vector<int>(n, 0); int w[3] = {a, b, c}; vector<int> q = {0, 1, 2}; sort(q.begin(), q.end(), [&](int x, int y){return w[x] < w[y];}); for(int i = 0; i < u.size(); i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } greedy(0, w[q[1]], q[1] + 1); for(int i = 0; i < n; i++){ if(!ans[i]){ greedy(i, w[q[0]], q[0] + 1); break; } } for(int i = 0; i < n; i++){ if(!ans[i]) ans[i] = q[2] + 1; } return ans; }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i = 0; i < u.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...