# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
873993 | The_Samurai | 별들과 삼각형 (IZhO11_triangle) | C++17 | 608 ms | 31096 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// #pragma GCC optimize("Ofast,O3")
// #pragma GCC target("avx,avx2")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
void solve() {
int n;
cin >> n;
set<pair<int, int>> st;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
st.emplace(x, y);
}
ll ans = 0;
map<int, vector<int>> mpx, mpy;
for (auto [x, y]: st) {
mpx[x].emplace_back(y);
mpy[y].emplace_back(x);
}
for (auto &it: mpx) sort(it.second.begin(), it.second.end());
for (auto &it: mpy) sort(it.second.begin(), it.second.end());
for (auto [x, y]: st) {
int px = upper_bound(mpx[x].begin(), mpx[x].end(), y) - mpx[x].begin();
int py = upper_bound(mpy[y].begin(), mpy[y].end(), x) - mpy[y].begin();
ans += 1ll * ((int) mpx[x].size() - px) * ((int) mpy[y].size() - py);
ans += 1ll * (px - 1) * ((int) mpy[y].size() - py);
ans += 1ll * ((int) mpx[x].size() - px) * (py - 1);
ans += 1ll * (px - 1) * (py - 1);
}
cout << ans;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int q = 1;
// cin >> q;
while (q--) {
solve();
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |