답안 #3401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3401 2013-08-31T05:30:57 Z waps12b Divide into triangle (kriii1_D) C++
컴파일 오류
0 ms 0 KB
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long 
struct pt{
	ll x,y;
	int pos;
	pt(){}
	pt(ll x,ll y){
		this->x=x;
		this->y=y;
	}
};
#define ccw(a,b,c) ( (a.x*b.y + b.x*c.y + c.x * a.y ) - ( a.y*b.x + b.y*c.x + c.y * a.x) )
pt v[300];
bool compare(pt &a,pt &b){
	return make_pair(a.x,a.y) < make_pair(b.x,b.y);
}
bool poscompare(pt &a,pt & b){
	return a.pos	 < b.pos;
}


int main(){
	int n;scanf("%d",&n);
	n*=3;
	for(int i=0;i<n;i++){
		ll x, y;scanf("%lld %lld",&x,&y);
		v[i] = pt(x,y);
		v[i].pos = i+1;
	}
	sort(v,v+n,compare);
	vector<string> ans;
	for(int i=0;i<n;i+=3){
		sort(v+i,v+i+3,poscompare);
		string t = "";
		t += (v[i].pos +'0');
		t += ' ';
		t += (v[i+1].pos+'0');
		t += ' ';
		t += (v[i+2].pos+'0');
		ans.push_back(t);
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++)
		printf("%s\n",ans[i].c_str());
	return 0;
}

Compilation message

D.cpp: In function 'int main()':
D.cpp:47:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
In file included from /usr/include/c++/4.6/algorithm:63:0,
                 from D.cpp:3:
/usr/include/c++/4.6/bits/stl_algo.h: In function '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = pt*, _Tp = pt, _Compare = bool (*)(pt&, pt&)]':
/usr/include/c++/4.6/bits/stl_algo.h:2265:78:   instantiated from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pt*, _Compare = bool (*)(pt&, pt&)]'
/usr/include/c++/4.6/bits/stl_algo.h:2306:62:   instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = pt*, _Size = long int, _Compare = bool (*)(pt&, pt&)]'
/usr/include/c++/4.6/bits/stl_algo.h:5445:4:   instantiated from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = pt*, _Compare = bool (*)(pt&, pt&)]'
D.cpp:34:20:   instantiated from here
/usr/include/c++/4.6/bits/stl_algo.h:2233:4: error: invalid initialization of reference of type 'pt&' from expression of type 'const pt'
/usr/include/c++/4.6/bits/stl_algo.h:2236:4: error: invalid initialization of reference of type 'pt&' from expression of type 'const pt'
D.cpp: In function 'int main()':
D.cpp:27:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
D.cpp:30:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]