답안 #671812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671812 2022-12-14T03:19:25 Z moday_morning 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
286 ms 9748 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 300000;

void usaco(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

map <int, int> x, y;
int a[1 + N][2];
 
void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i][0] >> a[i][1];
    }
    for (int i = 1; i <= n; i++) {
        x[a[i][0]]++;
        y[a[i][1]]++;
    }
    int sum = 0;
    for (int i = 1;i <= n; i++) {
        sum += 1LL * (x[a[i][0]] - 1) * (y[a[i][1]] - 1);
    }
    cout << sum << "\n";
}

signed main() {
    //usaco("triangles");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}

Compilation message

triangle.cpp: In function 'void usaco(std::string)':
triangle.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 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 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 6 ms 1232 KB Output is correct
14 Correct 9 ms 1768 KB Output is correct
15 Correct 106 ms 6412 KB Output is correct
16 Correct 106 ms 6588 KB Output is correct
17 Correct 93 ms 6312 KB Output is correct
18 Correct 94 ms 6364 KB Output is correct
19 Correct 256 ms 9312 KB Output is correct
20 Correct 188 ms 8176 KB Output is correct
21 Correct 286 ms 9748 KB Output is correct
22 Correct 274 ms 9692 KB Output is correct