| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 107067 | someone_aa | Star triangles (IZhO11_triangle) | C++17 | 1049 ms | 76364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 300100;
int x[maxn], y[maxn];
int n;
set<int>xst, yst;
map<int,int>xind, yind, cnt[maxn];
vector<int>xx[maxn], yy[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++) {
cin>>x[i]>>y[i];
xst.insert(x[i]);
yst.insert(y[i]);
}
int br = 1;
for(int i:xst) {
xind[i] = br++;
}
br = 1;
for(int i:yst) {
yind[i] = br++;
}
for(int i=1;i<=n;i++) {
x[i] = xind[x[i]];
y[i] = yind[y[i]];
xx[x[i]].pb(y[i]);
yy[y[i]].pb(x[i]);
}
for(int i=1;i<=n;i++) {
sort(yy[i].begin(), yy[i].end());
sort(xx[i].begin(), xx[i].end());
int br = 0;
for(int j:yy[i]) {
cnt[i][j] = br++;
}
}
ll result = 0LL;
for(int i=1;i<=n;i++) {
int br = 0;
for(int j:xx[i]) {
int curr_x = i;
int curr_y = j;
int lcnt = cnt[i][j];
int rcnt = yy[curr_y].size() - lcnt - 1;
int dcnt = br;
int ucnt = xx[i].size() - br - 1;
ll temp = 0LL;
temp += 1LL * lcnt * ucnt;
temp += 1LL * lcnt * dcnt;
temp += 1LL * rcnt * ucnt;
temp += 1LL * rcnt * dcnt;
result += temp;
br++;
}
}
cout<<result<<"\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
