# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4864 | tncks0121 | Star triangles (IZhO11_triangle) | C++98 | 216 ms | 8120 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.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |