답안 #671811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671811 2022-12-14T03:18:22 Z moday_morning 별들과 삼각형 (IZhO11_triangle) C++17
0 / 100
65 ms 588 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 Runtime error 65 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -