제출 #158957

#제출 시각아이디문제언어결과실행 시간메모리
158957georgerapeanuMeetings (JOI19_meetings)C++17
0 / 100
296 ms1068 KiB
#include "meetings.h" #pragma once #include <vector> #include <algorithm> #include <map> using namespace std; map<pair<int,int>,int> asked; int lvl[2005]; int my_query(int u,int v,int w){ u--; v--; w--; if(v == u || w == u){ return u + 1; } if(v == w){ return v + 1; } 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 ; } int node = nodes[rand() % (int)nodes.size()]; vector<int> path = {root,node}; map<int,vector<int> > subseq; for(auto it:nodes){ int tmp = my_query(root,it,node); if(tmp != node){ path.push_back(tmp); } subseq[tmp].push_back(it); } sort(path.begin(),path.end(),[&](int a,int b){return my_query(root,a,b) == a;}); for(int i = 1;i < (int)path.size();i++){ subseq[path[i - 1]].erase(find(subseq[path[i - 1]].begin(),subseq[path[i - 1]].end(),path[i])); my_bridge(path[i - 1],path[i]); } for(auto it:subseq){ solve(it.first,it.second); } } void Solve(int N) { srand(time(NULL)); vector<int> nodes; for(int i = 1;i <= N;i++){ nodes.push_back(i); } solve(1,nodes); }

컴파일 시 표준 에러 (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...