Submission #4864

#TimeUsernameProblemLanguageResultExecution timeMemory
4864tncks0121Star triangles (IZhO11_triangle)C++98
100 / 100
216 ms8120 KiB
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <deque> #include <utility> #include <bitset> #include <limits.h> #include <time.h> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef unsigned int uint; typedef long double llf; typedef pair<int, int> pii; const int N_ = 300005; int N, X[N_], Y[N_]; int *P[N_]; bool cmpP (const int *a, const int *b) { return *a < *b; } int CX[N_], CY[N_]; ll res; int main() { int i, j, k; scanf("%d", &N); for(i = 1; i <= N; i++) scanf("%d%d", X+i, Y+i); for(i = 1; i <= N; i++) P[i] = &X[i]; sort(P+1, P+N+1, cmpP); for(k = -1, j = 0, i = 1; i <= N; i++) { if(k != *P[i]) k = *P[i], ++j; *P[i] = j; } for(i = 1; i <= N; i++) P[i] = &Y[i]; sort(P+1, P+N+1, cmpP); for(k = -1, j = 0, i = 1; i <= N; i++) { if(k != *P[i]) k = *P[i], ++j; *P[i] = j; } for(i = 1; i <= N; i++) ++CX[X[i]], ++CY[Y[i]]; for(i = 1; i <= N; i++) { res += (ll) (CX[X[i]] - 1) * (CY[Y[i]] - 1); } printf("%lld\n", res); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...