# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1255250 | bonic | 별들과 삼각형 (IZhO11_triangle) | C++20 | 2 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
freopen("triangles.in","r",stdin);
int n; cin >> n; vector<int> X(n); vector<int> Y(n);
vector<pair<int, int>> A(n);
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
A[i] = {x, y};
X[i] = x; Y[i] = y;
}
sort(X.begin(), X.end()); sort(Y.begin(), Y.end()); int sum = 0;
for (int i = 0; i < n; i++) {
int q = A[i].first; int w = A[i].second;
int a = (upper_bound(X.begin(), X.end(), q) - X.begin()) - (lower_bound(X.begin(), X.end(), q) - X.begin());
int b = (upper_bound(Y.begin(), Y.end(), w) - Y.begin()) - (lower_bound(Y.begin(), Y.end(), w) - Y.begin());
// cout << a-1 << " " << b-1 << "\n";
sum += (a-1) * (b-1);
}
freopen("triangles.out","w",stdout);
cout << sum;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |