# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1085575 | Sunbae | 별들과 삼각형 (IZhO11_triangle) | C++17 | 208 ms | 11860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
#define mp make_pair
#define F first
#define S second
using namespace std;
using pii = pair<int,int>;
const int N = 3e5 + 5;
pii p[N];
int cp[2][N], m[2];
ll cnt[2][N];
int pos(int t, int x){ return lower_bound(cp[t], cp[t]+m[t], x) - cp[t];}
signed main(){
int n; scanf("%d", &n);
for(int i = 0, x, y; i<n; ++i){
scanf("%d %d", &x, &y);
p[i] = mp(x, y);
cp[0][m[0]++] = x;
cp[1][m[1]++] = y;
}
for(int j = 0; j<2; ++j) sort(cp[j], cp[j]+m[j]), m[j] = unique(cp[j], cp[j]+m[j]) - cp[j];
for(int i = 0; i<n; ++i) ++cnt[0][pos(0, p[i].F)], ++cnt[1][pos(1, p[i].S)];
ll tot = 0;
for(int i = 0; i<n; ++i){
int x = pos(0, p[i].F), y = pos(1, p[i].S);
tot += (cnt[0][x] - 1) * (cnt[1][y] - 1);
}
printf("%lld", tot);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |