Submission #1014805

#TimeUsernameProblemLanguageResultExecution timeMemory
1014805alex_2008Split the Attractions (IOI19_split)C++14
18 / 100
52 ms12756 KiB
#include "split.h" #include <iostream> #include <cmath> #include <vector> #include <set> #include <map> #include <algorithm> #include <queue> using namespace std; typedef long long ll; const int N = 1e5 + 10, M = 110; bool used[N]; vector <vector<int>> G; int sz; vector <int> esim; void dfs(int v) { if (used[v]) return; if ((int)esim.size() == sz) return; esim.push_back(v); used[v] = true; for (auto it : G[v]) { dfs(it); } } vector<int> find_split(int n, int A, int B, int C, vector<int> p, vector<int> q) { int m = (int)p.size(); bool sb1 = true, sb2 = true; G.resize(n); for (int i = 0; i < m; i++) { G[p[i]].push_back(q[i]); G[q[i]].push_back(p[i]); } for (int i = 0; i < n; i++) { if ((int)G[i].size() > 2) sb1 = false; } if (sb1) { int a = -1, b = -1; for (int i = 0; i < n; i++) { if ((int)G[i].size() == 1) { if (a == -1) a = i; else b = i; } } if (a == -1) a = 0; vector <int> v; v.push_back(a); v.push_back(G[a][0]); while ((int)v.size() < n) { int a = v[(int)v.size() - 1]; int b = v[(int)v.size() - 2]; if (G[a][0] == b) v.push_back(G[a][1]); else v.push_back(G[a][0]); } vector <int> ans(n); for (int i = 0; i < n; i++) { if (i < A) ans[v[i]] = 1; else if (i < A + B) ans[v[i]] = 2; else ans[v[i]] = 3; } return ans; } sb2 = (A == 1); if (sb2) { sz = B; dfs(0); vector <int> ans(n); bool al = true; for (int i = 0; i < n; i++) { if (used[i]) ans[i] = 2; else { if (al) { al = false; ans[i] = 1; } else ans[i] = 3; } } return ans; } } /*int main() { }*/

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:37:15: warning: variable 'b' set but not used [-Wunused-but-set-variable]
   37 |   int a = -1, b = -1;
      |               ^
split.cpp:80:1: warning: control reaches end of non-void function [-Wreturn-type]
   80 | }
      | ^
#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...