# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
585446 | Shin | 별들과 삼각형 (IZhO11_triangle) | C++14 | 367 ms | 53972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(), x.end()
using namespace std;
template <class X, class Y> bool minimize(X &a, Y b) {
if (a > b) return a = b, true;
return false;
}
template <class X, class Y> bool maximize(X &a, Y b) {
if (a < b) return a = b, true;
return false;
}
const int N = 6e5 + 7;
int n;
int x[N];
int y[N];
pair<int, int> a[N];
map<int, int> cnt[N];
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
vector<int> val;
for (int i = 1; i <= n; i ++) {
cin >> a[i].fi >> a[i].se;
val.push_back(a[i].fi);
val.push_back(a[i].se);
}
sort(all(val));
val.erase(unique(all(val)), val.end());
for (int i = 1; i <= n; i ++) {
a[i].fi = lower_bound(all(val), a[i].fi) - val.begin();
a[i].se = lower_bound(all(val), a[i].se) - val.begin();
x[a[i].fi] ++;
y[a[i].se] ++;
cnt[a[i].fi][a[i].se] ++;
}
long long res = 0;
for (int i = 1; i <= n; i ++) {
int hors = x[a[i].fi] - cnt[a[i].fi][a[i].se];
int vers = y[a[i].se] - cnt[a[i].fi][a[i].se];
res += 1LL * cnt[a[i].fi][a[i].se] * hors * vers;
}
cout << res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |