답안 #688635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
688635 2023-01-27T21:53:13 Z YENGOYAN 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
270 ms 13372 KB
/*
        //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
        \\                                    //
        //  271828___182845__904523__53602__  \\
        \\  87___47____13______52____66__24_  //
        //  97___75____72______47____09___36  \\
        \\  999595_____74______96____69___67  //
        //  62___77____24______07____66__30_  \\
        \\  35___35____47______59____45713__  //
        //                                    \\
        \\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
                                                    */

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <algorithm>
#include <random>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <tuple>
#include <bitset>
#include <chrono>
#include <ctime>
#include <fstream>
#include <stack>
#include <cstdio>

using namespace std;
using ll = long long;
const int N = 3e5 + 5;
const ll mod = 1e9 + 7, inf = 1e18;

void solve() {
    int n; cin >> n;
    map<int, int> x, y;
    vector<pair<int, int>> vp;
    for (int i = 0; i < n; ++i) {
        int xx, yy; cin >> xx >> yy;
        vp.push_back({ xx, yy });
        ++x[xx], ++y[yy];
    }
    ll ans = 0;
    for (int i = 0; i < vp.size(); ++i) {
        ans += (x[vp[i].first] - 1) * (y[vp[i].second] - 1);
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //int t; cin >> t;
    //while (t--)	
    solve();
}

Compilation message

triangle.cpp: In function 'void solve()':
triangle.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = 0; i < vp.size(); ++i) {
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 6 ms 980 KB Output is correct
13 Correct 6 ms 1100 KB Output is correct
14 Correct 9 ms 1364 KB Output is correct
15 Correct 93 ms 6128 KB Output is correct
16 Correct 108 ms 6600 KB Output is correct
17 Correct 97 ms 6068 KB Output is correct
18 Correct 91 ms 6076 KB Output is correct
19 Correct 252 ms 13372 KB Output is correct
20 Correct 185 ms 9180 KB Output is correct
21 Correct 269 ms 13320 KB Output is correct
22 Correct 270 ms 13360 KB Output is correct