# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
531725 | kebine | 별들과 삼각형 (IZhO11_triangle) | C++17 | 691 ms | 11988 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
pair<int, int> star[300005];
map<int, int> x, y;
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
cin >> star[i].first >> star[i].second;
//cout << star[i].first << " " << star[i].second << endl;
if(x.count(star[i].first) > 0) {
int now = x.find(star[i].first) -> second;
x.erase(star[i].first);
x.insert({star[i].first, now + 1});
//cout << "x" << now << endl;
}
else {
x.insert({star[i].first, 1});
}
if(y.count(star[i].second) > 0) {
int now = y.find(star[i].second) -> second;
y.erase(star[i].second);
y.insert({star[i].second, now + 1});
//cout << "y" << now << endl;
}
else {
y.insert({star[i].second, 1});
}
}
ll ans = 0;
for(int i = 0; i < n; i++) {
int hor = x.find(star[i].first) -> second;
hor--;
int ver = y.find(star[i].second) -> second;
ver--;
ans += 1ll * ver * hor;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |