답안 #4318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4318 2013-09-14T04:25:23 Z kipa00 Divide into triangle (kriii1_D) C++
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <algorithm>
using namespace std;

class Fence {
public:
	int x, y, n;
	bool operator<(Fence f) {
		bool res = x < f.x;
		if (x == f.x) {
			return y < f.y;
		}
		return res;
	}
};

int main() {
	Fence arr[900];
	int N, i;
	scanf("%d", &N);
	N *= 3;
	for (i=0; i<N; ++i) {
		Fence ff;
		int x, y;
		scanf("%d %d", &x, &y);
		ff.x = x; ff.y = y;
		ff.n = i + 1;
		arr[i] = ff;
	}
	sort(arr, arr+N);
	for (i=0; i<N;) {
		printf("%d ", arr[i].n);
		if (!((++i) % 3)) {
			printf("\n");
		}
	}
	return 0;
}

Compilation message

In file included from /usr/include/c++/4.6/algorithm:63:0,
                 from D.cpp:2:
/usr/include/c++/4.6/bits/stl_algo.h: In function '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = Fence*, _Tp = Fence]':
/usr/include/c++/4.6/bits/stl_algo.h:2253:70:   instantiated from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Fence*]'
/usr/include/c++/4.6/bits/stl_algo.h:2284:54:   instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = Fence*, _Size = long int]'
/usr/include/c++/4.6/bits/stl_algo.h:5407:4:   instantiated from 'void std::sort(_RAIter, _RAIter) [with _RAIter = Fence*]'
D.cpp:30:17:   instantiated from here
/usr/include/c++/4.6/bits/stl_algo.h:2215:4: error: passing 'const Fence' as 'this' argument of 'bool Fence::operator<(Fence)' discards qualifiers [-fpermissive]
D.cpp: In function 'int main()':
D.cpp:20:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
D.cpp:25:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]