Submission #120398

#TimeUsernameProblemLanguageResultExecution timeMemory
120398pavelMeetings (JOI19_meetings)C++14
100 / 100
1181 ms1032 KiB
#include <vector> #include <map> #include <algorithm> #include <cstdlib> #include "meetings.h" using namespace std; struct cmp{ int a; cmp(int b){ a=b; } bool operator()(int x, int y){ if(x==a) return y!=a; if(y==a) return false; return Query(a, x, y)==x; } }; void SolveSubTree(vector<int> nodes){ if(nodes.size()<=1) return; int a=rand()%nodes.size(), b=rand()%nodes.size(); while(a==b){ b=rand()%nodes.size(); } a=nodes[a];b=nodes[b]; map<int, vector<int>> sts; sts[a].push_back(a); sts[b].push_back(b); for(int j=0;j<nodes.size();++j){ if(nodes[j]!=a && nodes[j]!=b){ int x = Query(a, b, nodes[j]); sts[x].push_back(nodes[j]); } } vector<int> path; for(auto i:sts){ path.push_back(i.first); } sort(path.begin(), path.end(), cmp(a)); for(int i=1;i<path.size();++i){ int x=min(path[i-1], path[i]); int y=max(path[i-1], path[i]); Bridge(x, y); } for(auto i:sts){ SolveSubTree(i.second); } } void Solve(int N) { vector<int> s; for(int i=0;i<N;++i) s.push_back(i); SolveSubTree(s); }

Compilation message (stderr)

meetings.cpp: In function 'void SolveSubTree(std::vector<int>)':
meetings.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<nodes.size();++j){
                 ~^~~~~~~~~~~~~
meetings.cpp:46:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<path.size();++i){
                 ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...