# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
968025 | tset | Star triangles (IZhO11_triangle) | C++14 | 223 ms | 21408 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 pii pair<int, int>
int firstEqual(vector<int>& v, int nb)
{
int pos = -1;
int pas = 1 << 20;
while(pas>0)
{
int test = pos + pas;
if(test < v.size())
{
if(v[test] < nb)
{
pos += pas;
}
}
pas /= 2;
}
return pos +1;
}
int nbAxis(vector<int>& v, int nb)
{
return firstEqual(v, nb+1) - firstEqual(v, nb);
}
signed main()
{
int N;
scanf("%lld", &N);
vector<int > X, Y;
vector<pii> coords;
for(int iN = 0; iN < N; iN++)
{
int x, y;
scanf("%lld%lld", &x, &y);
X.push_back(x);
Y.push_back(y);
coords.push_back({x, y});
}
sort(X.begin(), X.end());
sort(Y.begin(), Y.end());
int ans= 0;
for(pii coord : coords)
{
int x = coord.first;
int y = coord.second;
int cx = nbAxis(X, x) -1;
int cy = nbAxis(Y, y) -1;
ans += cx * cy;
}
printf("%lld\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |