| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 754130 | thimote75 | 별들과 삼각형 (IZhO11_triangle) | C++14 | 418 ms | 12472 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using idata = vector<int>;
using ipair = pair<int, int>;
using ipdata = vector<ipair>;
using num = long long;
idata X, Y;
ipdata stars;
int find (idata &axis, int x) {
int a = -1;
int b = axis.size();
while ( b - a > 1 ) {
int c = (a + b) >> 1;
if (axis[c] < x) a = c;
else b = c;
}
return b;
}
int count (idata &axis, int v) {
int l = find(axis, v);
int r = find(axis, v + 1);
return r - l;
}
int main () {
int N;
cin >> N;
for (int i = 0; i < N; i ++) {
int x, y;
cin >> x >> y;
X.push_back(x);
Y.push_back(y);
stars.push_back({ x, y });
}
sort(X.begin(), X.end());
sort(Y.begin(), Y.end());
num result = 0;
for (ipair star : stars) {
int x = star.first;
int y = star.second;
num cx = count(X, x) - 1;
num cy = count(Y, y) - 1;
result += cx * cy;
}
cout << result << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
