# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
960636 | starchan | Star triangles (IZhO11_triangle) | C++17 | 1 ms | 348 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 in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int MX = 3e5+5;
int cnt[MX][2];
signed main()
{
fast();
int n;
cin >> n;
array<int, 2> pt[n];
for(int i = 0; i < n; i++)
cin >> pt[i][0] >> pt[i][1];
vector<int> V;
for(int i = 0; i < n; i++)
V.pb(pt[i][0]);
sort(V.begin(), V.end());
vector<int> M; M.pb(V[0]);
for(int k: V)
{
if(k != M.back())
M.pb(k);
}
for(int i = 0; i < n; i++)
{
pt[i][0] = lower_bound(M.begin(), M.end(), pt[i][0])-M.begin();
cnt[pt[i][0]][0]++;
}
V.clear();
M.clear();
for(int i = 0; i < n; i++)
V.pb(pt[i][0]);
sort(V.begin(), V.end());
M.pb(V[0]);
for(int k: V)
{
if(k != M.back())
M.pb(k);
}
for(int i = 0; i < n; i++)
{
pt[i][1] = lower_bound(M.begin(), M.end(), pt[i][1])-M.begin();
cnt[pt[i][1]][1]++;
}
int ans = 0;
for(int i = 0; i < n; i++)
ans+=((cnt[pt[i][0]][0]-1)*(cnt[pt[i][1]][1]-1));
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |