답안 #207026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207026 2020-03-06T06:43:19 Z pavement 별들과 삼각형 (IZhO11_triangle) C++17
0 / 100
5 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, C, X[300005], Y[300005];
map<int, vector<int> > XC, YC;

main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i];
		XC[X[i]].push_back(Y[i]);
		YC[Y[i]].push_back(X[i]);
	}
	for (int i = 1; i <= N; i++) {
		auto it = upper_bound(YC[Y[i]].begin(), YC[Y[i]].end(), X[i]), it2 = upper_bound(XC[X[i]].begin(), XC[X[i]].end(), Y[i]);
		C += (YC[Y[i]].size() - (it - YC[Y[i]].begin())) * (XC[X[i]].size() - (it2 - XC[X[i]].begin()));
	}
	for (int i = 1; i <= N; i++) {
		auto it = upper_bound(YC[Y[i]].begin(), YC[Y[i]].end(), X[i]), it2 = lower_bound(XC[X[i]].begin(), XC[X[i]].end(), Y[i]);
		C += (YC[Y[i]].size() - (it - YC[Y[i]].begin())) * (it2 - XC[X[i]].begin());
	}
	for (int i = 1; i <= N; i++) {
		auto it = lower_bound(YC[Y[i]].begin(), YC[Y[i]].end(), X[i]), it2 = upper_bound(XC[X[i]].begin(), XC[X[i]].end(), Y[i]);
		C += (it - YC[Y[i]].begin()) * (XC[X[i]].size() - (it2 - XC[X[i]].begin()));
	}
	for (int i = 1; i <= N; i++) {
		auto it = lower_bound(YC[Y[i]].begin(), YC[Y[i]].end(), X[i]), it2 = lower_bound(XC[X[i]].begin(), XC[X[i]].end(), Y[i]);
		C += (it - YC[Y[i]].begin()) * (it2 - XC[X[i]].begin());
	}
	cout << C << '\n';
}

Compilation message

triangle.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Incorrect 5 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -