Submission #529792

#TimeUsernameProblemLanguageResultExecution timeMemory
529792Koosha_mvMeetings (JOI19_meetings)C++14
100 / 100
644 ms832 KiB
#include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first #include "meetings.h" void findpath(vector<int> p){ vector<int> res; if(p.size()<2) assert(0); res.pb(p[0]); res.pb(p[1]); f(i,2,p.size()){ int u=p[i]; int l,r; if(Query(u,res[0],res[1])==res[0]){ l=-1,r=0; } else if(Query(u,res[res.size()-1],res[res.size()-2])==res[res.size()-1]){ r=res.size(); } else{ l=0,r=res.size(); while(l+1<r){ int mid=(l+r)>>1; if(Query(u,res[mid],res[mid-1])==res[mid]) l=mid; else r=mid; } } vector<int> pes; f(i,0,res.size()){ if(i==r) pes.pb(u); pes.pb(res[i]); } if(r==res.size()) pes.pb(u); res.clear(); for(auto x : pes) res.pb(x); } f(i,1,res.size()){ Bridge(min(res[i],res[i-1]),max(res[i],res[i-1])); } } void solve(vector<int> vec){ if(vec.size()==1) return ; vector<int> path; vector<pair<int,int>> e; int u=0,v=0; while(u==v) u=rand()%vec.size(),v=rand()%vec.size(); u=vec[u],v=vec[v]; e.pb({u,u}); e.pb({v,v}); for(auto x : vec){ if(x==u || x==v) continue ; e.pb({Query(x,u,v),x}); } sort(all(e)); vec.clear(); f(i,0,e.size()){ vec.pb(e[i].S); if(i==e.size()-1 || e[i].F!=e[i+1].F){ path.pb(e[i].F); solve(vec); vec.clear(); } } findpath(path); } void Solve(int pn){ vector<int> vec(pn); iota(all(vec),0); solve(vec); }

Compilation message (stderr)

meetings.cpp: In function 'void findpath(std::vector<int>)':
meetings.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   29 |  f(i,2,p.size()){
      |    ~~~~~~~~~~~~                
meetings.cpp:29:2: note: in expansion of macro 'f'
   29 |  f(i,2,p.size()){
      |  ^
meetings.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   47 |   f(i,0,res.size()){
      |     ~~~~~~~~~~~~~~             
meetings.cpp:47:3: note: in expansion of macro 'f'
   47 |   f(i,0,res.size()){
      |   ^
meetings.cpp:51:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   if(r==res.size()) pes.pb(u);
      |      ~^~~~~~~~~~~~
meetings.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   55 |  f(i,1,res.size()){
      |    ~~~~~~~~~~~~~~              
meetings.cpp:55:2: note: in expansion of macro 'f'
   55 |  f(i,1,res.size()){
      |  ^
meetings.cpp: In function 'void solve(std::vector<int>)':
meetings.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   74 |  f(i,0,e.size()){
      |    ~~~~~~~~~~~~                
meetings.cpp:74:2: note: in expansion of macro 'f'
   74 |  f(i,0,e.size()){
      |  ^
meetings.cpp:76:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |   if(i==e.size()-1 || e[i].F!=e[i+1].F){
      |      ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...