# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
207026 | pavement | Star triangles (IZhO11_triangle) | C++17 | 5 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |