제출 #344244

#제출 시각아이디문제언어결과실행 시간메모리
344244KerimMeetings (JOI19_meetings)C++17
컴파일 에러
0 ms0 KiB
#include "meetings.h"
#include "bits/stdc++.h"
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)

using namespace std;
int root;
bool cmp(int x,int y){
	return (Query(root,x,y)==x);
}
void print(int x,int y){
	if(x>y)swap(x,y);
	Bridge(x,y);	
}
void f(vector<int>v){
	int sz=int(v.size());
	if(sz<2)
		return;
	if(sz==2){
		print(v[0],v[1]);
		return;	
	}
	int a=rand()%sz,b=rand()%sz;
	while(a==b)b=rand()%sz;
	int a=0,b=1;
	a=v[a];b=v[b];root=a;
	map<int,vector<int> >pm;
	vector<int>tmp;
	tr(it,v)
		if(*it!=a && *it!=b){
			int c=Query(a,b,*it);
			if(!pm.count(c) && c!=a && c!=b)
				tmp.push_back(c);
			pm[c].push_back(*it);	
		}
	pm[a].push_back(a);pm[b].push_back(b);
	if(tmp.empty())
		print(a,b);
	else{
		sort(tmp.begin(),tmp.end(),cmp);
		print(a,tmp[0]);
		for(int i=0;i<int(tmp.size())-1;i++)
			print(tmp[i],tmp[i+1]);
		print(tmp.back(),b);
	}
	tr(it,pm)f(it->second);
}
void Solve(int N){
	srand((unsigned)time(NULL));
	vector<int>v;
	for(int i=0;i<N;i++)
		v.push_back(i);
	f(v);
}

컴파일 시 표준 에러 (stderr) 메시지

meetings.cpp: In function 'void f(std::vector<int>)':
meetings.cpp:24:6: error: redeclaration of 'int a'
   24 |  int a=0,b=1;
      |      ^
meetings.cpp:22:6: note: 'int a' previously declared here
   22 |  int a=rand()%sz,b=rand()%sz;
      |      ^
meetings.cpp:24:10: error: redeclaration of 'int b'
   24 |  int a=0,b=1;
      |          ^
meetings.cpp:22:18: note: 'int b' previously declared here
   22 |  int a=rand()%sz,b=rand()%sz;
      |                  ^