답안 #529767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529767 2022-02-23T15:40:34 Z Koosha_mv Meetings (JOI19_meetings) C++14
0 / 100
60 ms 964 KB
#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"

const int N=2020;

int n,rt;
vector<int> g[N];
/*
void Bridge(int u, int v){
	cout<<"BRIDGE "<<u<<" "<<v<<endl;
}
int Query(int u, int v, int w){
	int x;
	cout<<"QUERY "<<u<<" "<<v<<" "<<w<<endl;	
	cin>>x;
	return x;
}*/
bool cmp(int i,int j){
	if(i==rt) return 1;
	if(j==rt) return 0;
	return Query(i,j,rt)==i;
}
void findpath(vector<int> p){
	rt=-1;
	f(i,0,p.size()){
		int check=1;
		f(j,0,p.size()){
			f(k,j+1,p.size()){
				if(j!=i && k!=i && Query(p[i],p[j],p[k])){
					check=0;
				}
			}
		}
		if(check){
			rt=p[i];
			break;
		}
	}
	if(rt==-1) assert(0);
	vector<int> res;
	for(auto x : p) res.pb(x);
	sort(all(res),cmp);
	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=1;
	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){
	n=pn;
	vector<int> vec(n);
	iota(all(vec),0);
	solve(vec);
}
/*
int main(){
	srand(time(NULL));
	cin>>n;
	f(i,1,n){
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	Solve(n);
}
*/

Compilation message

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++)
......
   45 |  f(i,0,p.size()){
      |    ~~~~~~~~~~~~                
meetings.cpp:45:2: note: in expansion of macro 'f'
   45 |  f(i,0,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(j,0,p.size()){
      |     ~~~~~~~~~~~~               
meetings.cpp:47:3: note: in expansion of macro 'f'
   47 |   f(j,0,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++)
......
   48 |    f(k,j+1,p.size()){
      |      ~~~~~~~~~~~~~~            
meetings.cpp:48:4: note: in expansion of macro 'f'
   48 |    f(k,j+1,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++)
......
   63 |  f(i,1,res.size()){
      |    ~~~~~~~~~~~~~~              
meetings.cpp:63:2: note: in expansion of macro 'f'
   63 |  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++)
......
   82 |  f(i,0,e.size()){
      |    ~~~~~~~~~~~~                
meetings.cpp:82:2: note: in expansion of macro 'f'
   82 |  f(i,0,e.size()){
      |  ^
meetings.cpp:84: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]
   84 |   if(i==e.size()-1 || e[i].F!=e[i+1].F){
      |      ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Runtime error 1 ms 584 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Runtime error 1 ms 584 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Runtime error 1 ms 584 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 60 ms 964 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -