# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1112585 | Chinguun | Star triangles (IZhO11_triangle) | C++14 | 391 ms | 15432 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
#define ff first
#define ss second
#define pb push_back
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int n, x, y, ans;
map <int, vi> mp;
map <int, pii> p;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x >> y;
mp[x].pb (y);
p[y].ff++;
}
for (auto it : mp) {
vi v = it.ss;
for (int i = 0; i < v.size (); i++) {
ans += i * (p[v[i]].ss + p[v[i]].ff - 1);
ans += (v.size () - i - 1) * (p[v[i]].ss + p[v[i]].ff - 1);
p[v[i]].ff--; p[v[i]].ss++;
}
}
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |