# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
989788 | tch1cherin | Star triangles (IZhO11_triangle) | C++17 | 471 ms | 20428 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N;
cin >> N;
vector<int> X(N), Y(N);
for (int i = 0; i < N; i++) {
cin >> X[i] >> Y[i];
}
map<int, vector<int>> pos_x, pos_y;
for (int i = 0; i < N; i++) {
pos_x[X[i]].push_back(Y[i]);
pos_y[Y[i]].push_back(X[i]);
}
long long answer = 0;
for (int i = 0; i < N; i++) {
int px = lower_bound(pos_x[X[i]].begin(), pos_x[X[i]].end(), Y[i]) - pos_x[X[i]].begin();
int xs = (int)pos_x[X[i]].size();
int py = lower_bound(pos_y[Y[i]].begin(), pos_y[Y[i]].end(), X[i]) - pos_y[Y[i]].begin();
int ys = (int)pos_y[Y[i]].size();
answer += 1LL * px * py + 1LL * px * (ys - 1 - py) + 1LL * (xs - 1 - px) * py + 1LL * (xs - 1 - px) * (ys - 1 - py);
}
cout << answer << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |