Submission #158948

#TimeUsernameProblemLanguageResultExecution timeMemory
158948georgerapeanuMeetings (JOI19_meetings)C++14
0 / 100
32 ms524 KiB
#include "meetings.h" #pragma once #include <vector> #include <algorithm> using namespace std; int my_query(int u,int v,int w){ u--; v--; w--; /// printf("%d %d %d\n",u,v,w); return Query(u,v,w) + 1; } void my_bridge(int u,int v){ u--; v--; if(u > v){ swap(u,v); } /// printf("%d %d\n",u,v); Bridge(u,v); } void solve(int root,vector<int> &nodes){ for(int i = 0;i < (int)nodes.size();i++){ if(nodes[i] == root){ swap(nodes[i],nodes.back()); nodes.pop_back(); break; } } if(nodes.size() == 0){ return; } if(nodes.size() == 1){ my_bridge(root,nodes[0]); return ; } vector<pair<pair<int,int>,vector<int> > > sons;sons.clear(); for(auto it:nodes){ sort(sons.begin(),sons.end()); reverse(sons.begin(),sons.end()); bool ins = false; for(int i = 0;i < (int)sons.size();i++){ int tmp = my_query(root,sons[i].first.second,it); if(tmp != root){ sons[i].first.second = tmp; sons[i].first.first++; sons[i].second.push_back(it); ins = true; break; } } if(ins == false){ sons.push_back({{1,it},{it}}); } } for(int i = 0;i < (int)sons.size();i++){ my_bridge(root,sons[i].first.second); } for(int i = 0;i < (int)sons.size();i++){ solve(sons[i].first.second,sons[i].second); } } void Solve(int N) { vector<int> nodes; for(int i = 1;i <= N;i++){ nodes.push_back(i); } solve(1,nodes); }

Compilation message (stderr)

meetings.cpp:2:9: warning: #pragma once in main file
 #pragma once
         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...