Submission #294961

#TimeUsernameProblemLanguageResultExecution timeMemory
294961Ruba_KSplit the Attractions (IOI19_split)C++14
7 / 100
118 ms13816 KiB
#include "split.h" #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5 ; vector<int>adj[N]; vector<int> res ; map<int , int > foreach; int vis[N] , degree[N]; int arr[5]; void dfs(int u , int id , int sz ){ if(sz == arr[id])id++ , sz = 0 ; vis[u] ++ ; res[u] = id ; for(auto f : adj[u]){ if(vis[f]) continue ; dfs(f , id , sz + 1); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { res.resize(n); arr[1] = a , arr[2] = b , arr[3] = c ; int m = p.size(); for(int i = 0 ; i < m ; i ++){ adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); degree[p[i]]++ , degree[q[i]]++; } int mn = 3 , start ; for(int i = 0 ; i < m ; i ++){ if(degree[i] < mn) mn = degree[i] , start = i ; } dfs(start , 1 , 0); 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:40:5: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |  dfs(start , 1 , 0);
      |  ~~~^~~~~~~~~~~~~~~
#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...