Submission #436428

#TimeUsernameProblemLanguageResultExecution timeMemory
436428mat_vSimurgh (IOI17_simurgh)C++14
0 / 100
1 ms332 KiB
#include "simurgh.h" #include <bits/stdc++.h> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define pb push_back #define pii pair<int,int> #define xx first #define yy second using namespace std; int disc[505]; bool bio[505]; vector<pii> graf[505]; pii cale[505]; vector<pii> gore[505]; int br=1; void dfs(int x){ disc[x] = br; bio[x] = 1; for(auto c:graf[x]){ if(bio[c.xx])continue; cale[c.xx] = {x,c.yy}; br++; dfs(c.xx); } } set<int> s; int pitaj(){ vector<int> r; for(auto c:s)r.pb(c); return count_common_roads(r); } std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { std::vector<int> r(n - 1); int m = u.size(); ff(i,0,m - 1){ graf[u[i]].pb({v[i],i}); graf[v[i]].pb({u[i],i}); } ff(i,0,n - 1)cale[i].xx = -1; dfs(0); ff(i,0,m - 1){ int prvi = u[i]; int drugi = v[i]; if(cale[prvi].xx == drugi || cale[drugi].xx == prvi)continue; if(disc[prvi] < disc[drugi]){ gore[drugi].pb({prvi,i}); } else gore[prvi].pb({drugi,i}); } ff(i,0,m - 1){ if(cale[u[i]].xx == v[i] || cale[v[i]].xx == u[i])s.insert(i); } //cout << "kurcina\n"; int poc = pitaj(); vector<int> ans; vector<pii> sad; ff(i,1,n - 1){ sad.clear(); int mks = poc; sad.pb({poc,cale[i].yy}); for(auto c:gore[i]){ s.erase(cale[i].yy); s.insert(c.yy); int sta = pitaj(); mks = max(mks, sta); sad.pb({sta, c.yy}); s.erase(c.yy); s.insert(cale[i].yy); } for(auto c:sad){ if(c.xx == mks)ans.pb(c.yy); } } return ans; } /* 4 6 0 1 0 2 0 3 1 2 1 3 2 3 0 1 5 */

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
simurgh.cpp:41:5: note: in expansion of macro 'ff'
   41 |     ff(i,0,m - 1){
      |     ^~
simurgh.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
simurgh.cpp:45:5: note: in expansion of macro 'ff'
   45 |     ff(i,0,n - 1)cale[i].xx = -1;
      |     ^~
simurgh.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
simurgh.cpp:47:5: note: in expansion of macro 'ff'
   47 |     ff(i,0,m - 1){
      |     ^~
simurgh.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
simurgh.cpp:56:5: note: in expansion of macro 'ff'
   56 |     ff(i,0,m - 1){
      |     ^~
simurgh.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
simurgh.cpp:63:5: note: in expansion of macro 'ff'
   63 |     ff(i,1,n - 1){
      |     ^~
#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...