답안 #1109686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109686 2024-11-07T10:12:31 Z Anar 별들과 삼각형 (IZhO11_triangle) C++14
100 / 100
231 ms 22156 KB
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <array>
#include <map>
#include <iterator>

using namespace std;

#define pb push_back
#define ll long long
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);

typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int n, ans;
vi starx, stary;
vii star;

map <int, int> mpx;
map <int, int> mpy;

void preprocess() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        starx.pb(x);
        stary.pb(y);
        star.pb({x, y});
    }
    sort(starx.begin(), starx.end());
    sort(stary.begin(), stary.end());
}

void mainprocess() {
    for (int i = 0; i < n; i++) {
        mpx[starx[i]] ++;
        mpy[stary[i]] ++;
    }
    for (int i = 0; i < n; i++) {
        ans += (mpx[star[i].ff] - 1) *  (mpy[star[i].ss] - 1);
    }
}

signed main() {
    fastio;
    preprocess();
    mainprocess();
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 424 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 5 ms 1244 KB Output is correct
13 Correct 6 ms 1360 KB Output is correct
14 Correct 8 ms 1616 KB Output is correct
15 Correct 83 ms 7856 KB Output is correct
16 Correct 86 ms 8112 KB Output is correct
17 Correct 78 ms 7664 KB Output is correct
18 Correct 80 ms 7656 KB Output is correct
19 Correct 202 ms 21640 KB Output is correct
20 Correct 144 ms 13992 KB Output is correct
21 Correct 231 ms 22156 KB Output is correct
22 Correct 219 ms 22156 KB Output is correct