Submission #90341

# Submission time Handle Problem Language Result Execution time Memory
90341 2018-12-21T09:32:25 Z Bodo171 Star triangles (IZhO11_triangle) C++14
100 / 100
967 ms 11716 KB
#include <iostream>
#include <map>
#include <algorithm>
#define x first
#define y second
using namespace std;
const int nmax=300005;
map<int,int> X,Y;
pair<int,int> v[nmax];
int n,i;
long long ans;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>v[i].x>>v[i].y;
    for(int cc=0;cc<4;cc++)
    {
        for(i=1;i<=n;i++)
        {
            if(cc>0)
            {
                v[i].x*=-1;
                if((cc&2)!=((cc-1)&2))
                    v[i].y*=-1;
            }
        }
        sort(v+1,v+n+1);
        for(i=n;i>=1;i--)
       {
        ans+=1LL*X[v[i].x]*Y[v[i].y];
        X[v[i].x]++,Y[v[i].y]++;
       }
       X.clear();Y.clear();
    }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 456 KB Output is correct
5 Correct 2 ms 456 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 2 ms 508 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 516 KB Output is correct
10 Correct 2 ms 580 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 20 ms 1328 KB Output is correct
13 Correct 19 ms 1424 KB Output is correct
14 Correct 30 ms 2020 KB Output is correct
15 Correct 306 ms 7100 KB Output is correct
16 Correct 322 ms 9508 KB Output is correct
17 Correct 299 ms 9792 KB Output is correct
18 Correct 300 ms 9792 KB Output is correct
19 Correct 786 ms 11528 KB Output is correct
20 Correct 621 ms 11528 KB Output is correct
21 Correct 904 ms 11684 KB Output is correct
22 Correct 967 ms 11716 KB Output is correct