답안 #4164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4164 2013-09-02T15:47:57 Z gudbooy Divide into triangle (kriii1_D) C++
컴파일 오류
0 ms 0 KB
#include<iostream>
#include<string.h>
#include<string>
#include<vector>
#include<iterator>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<cmath>
using namespace std;
#define MAXN 900
#define INF 987654321
int N;
int locate[MAXN][2];
double calcdis(int x1, int y1, int x2, int y2)
{
	int x, y;
	x=x1-x2;
	y=y1-y2; 
	double sum = pow(x, 2)+pow(y, 2);
	return sqrt(sum);
}
void algorithm()
{
	
	int count = 0;
	for(int i=0; i<(3*N); i++){
		if(locate[i][0] != INF && locate[i][1] != INF){
		vector<pair<double, int>> p;
		for(int j=i+1; j<(3*N); j++)
		{
			if(locate[j][0] != INF && locate[j][1] != INF){
			  p.push_back(make_pair(calcdis(locate[i][0], locate[i][1], locate[j][0], locate[j][1]), j));
			}
		}
			sort(p.begin(), p.end());
			int x = locate[p[0].second][0];
			int y = locate[p[0].second][1];
			locate[p[0].second][0] = locate[p[0].second][1] = INF;
			vector<pair<double, int>> p1;
		for(int j=i+1; j<(3*N); j++)
		{
			if(locate[j][0] != INF && locate[j][1] != INF){
			  p1.push_back(make_pair(calcdis(x, y, locate[j][0], locate[j][1]), j));
			}
		}	
			sort(p1.begin(), p1.end());
			cout << i+1 << " " << (p[0].second)+1 << " " << (p1[0].second)+1<<endl;
			locate[p1[0].second][0] = locate[p1[0].second][1] = INF;
			locate[i][0] = locate[i][0] = INF;
		}
	}
}
void test()
{
	cin >> N;
	for(int i=0; i<(3*N); i++)
	{
		cin >> locate[i][0] >> locate[i][1];
	}
	algorithm();
}
int main()
{
		test();		
}

Compilation message

D.cpp: In function 'void algorithm()':
D.cpp:32:26: error: '>>' should be '> >' within a nested template argument list
D.cpp:43:27: error: '>>' should be '> >' within a nested template argument list
D.cpp:53:37: warning: operation on 'locate[i][0]' may be undefined [-Wsequence-point]
D.cpp:29:6: warning: unused variable 'count' [-Wunused-variable]