Submission #685270

# Submission time Handle Problem Language Result Execution time Memory
685270 2023-01-23T19:55:56 Z White Star triangles (IZhO11_triangle) C++14
100 / 100
210 ms 24344 KB
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

pair<long long,long long>red[300005];
long long ans=0,cnt=0;
vector<long long>x[300005];
map<long long,long long>y;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long n;
    cin>>n;
    for(int i=0;i<n;i++){
        long long A,B;
        cin>>A>>B;
        red[i]=make_pair(A+1000000000,B+1000000000);
        y[B+1000000000]++;
    }
    sort(red,red+n);
    x[0].push_back(red[0].second);
    for(int i=1;i<n;i++){
        if(red[i].first==red[i-1].first){
            x[cnt].push_back(red[i].second);
        }else{
            cnt++;
            x[cnt].push_back(red[i].second);
        }
    }

    for(int i=0;i<=cnt;i++){
        for(int j=0;j<x[i].size();j++){
            ans+=(x[i].size()-1)*(y[x[i][j]]-1);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int j=0;j<x[i].size();j++){
      |                     ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7252 KB Output is correct
2 Correct 5 ms 7252 KB Output is correct
3 Correct 5 ms 7360 KB Output is correct
4 Correct 5 ms 7252 KB Output is correct
5 Correct 4 ms 7380 KB Output is correct
6 Correct 5 ms 7300 KB Output is correct
7 Correct 5 ms 7380 KB Output is correct
8 Correct 5 ms 7380 KB Output is correct
9 Correct 6 ms 7380 KB Output is correct
10 Correct 5 ms 7376 KB Output is correct
11 Correct 5 ms 7380 KB Output is correct
12 Correct 14 ms 8296 KB Output is correct
13 Correct 9 ms 8148 KB Output is correct
14 Correct 11 ms 8540 KB Output is correct
15 Correct 78 ms 14508 KB Output is correct
16 Correct 91 ms 14940 KB Output is correct
17 Correct 81 ms 14516 KB Output is correct
18 Correct 82 ms 14436 KB Output is correct
19 Correct 197 ms 23100 KB Output is correct
20 Correct 146 ms 19356 KB Output is correct
21 Correct 208 ms 24344 KB Output is correct
22 Correct 210 ms 24256 KB Output is correct