제출 #107067

#제출 시각아이디문제언어결과실행 시간메모리
107067someone_aa별들과 삼각형 (IZhO11_triangle)C++17
100 / 100
1049 ms76364 KiB
#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) 메시지

triangle.cpp: In function 'int main()':
triangle.cpp:58:17: warning: unused variable 'curr_x' [-Wunused-variable]
             int curr_x = i;
                 ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...