Submission #938927

#TimeUsernameProblemLanguageResultExecution timeMemory
938927MackerSimurgh (IOI17_simurgh)C++17
0 / 100
0 ms348 KiB
#include "simurgh.h" #include <bits/stdc++.h> typedef long long ll; #define pii pair<int, int> #define fi first #define se second #define all(v) v.begin(), v.end() #define FOR(i, n) for (int i = 0; i < n; i++) using namespace std; set<pii> cur; map<pii, int> fin; map<pii, int> label; vector<vector<int>> adj; vector<int> vis; vector<int> tovec(set<pii> a){ vector<int> res; for (auto &i : a) { res.push_back(label[i]); } return res; } pii sdfs(int a, int p){ vis[a] = 2; pii res = {1, 0}; for (auto &b : adj[a]) { if(vis[b] != 2) { pii ret = sdfs(b, a); res.fi += ret.fi; res.se += ret.se; } } if(a == 0) return res; int base = count_common_roads(tovec(cur)); cur.erase({p, a}); set<int> samepar; bool parroyal = (res.se < res.fi); for (auto &b : adj[a]) { if(cur.find({a, b}) == cur.end() && cur.find({b, a}) == cur.end()){ cur.insert({a, b}); int cnt = count_common_roads(tovec(cur)); cur.erase({a, b}); if(cnt == base) samepar.insert(b); if(cnt < base) parroyal = 1; if(cnt > base) parroyal = 0; } } for (auto &b : adj[a]) { if(cur.find({a, b}) == cur.end() && cur.find({b, a}) == cur.end()){ if(samepar.find(b) != samepar.end()){ if(parroyal) { fin[{a, b}] = 1; res.se++; } } else { if(!parroyal) { fin[{a, b}] = 1; res.se++; } } } } cur.insert({p, a}); return res; } void dfs(int a){ vis[a] = 1; for (auto &b : adj[a]) { if(!vis[b]) { cur.insert({a, b}); dfs(b); } } } vector<int> find_roads(int n, vector<int> u, vector<int> v) { adj.resize(n); vis.resize(n); FOR(i, u.size()){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); label[{u[i], v[i]}] = i; label[{v[i], u[i]}] = i; } dfs(0); sdfs(0, 0); vector<int> res; for (auto &i : fin) { if(i.se == 1) res.push_back(label[i.fi]); } return res; }

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:9:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, n) for (int i = 0; i < n; i++)
......
   86 |  FOR(i, u.size()){
      |      ~~~~~~~~~~~                     
simurgh.cpp:86:2: note: in expansion of macro 'FOR'
   86 |  FOR(i, u.size()){
      |  ^~~
#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...