답안 #413427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
413427 2021-05-28T17:31:03 Z aris12345678 별들과 삼각형 (IZhO11_triangle) C++14
100 / 100
396 ms 12164 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 300005;
int x[mxN], y[mxN];

int main() {
    int n;
    scanf("%d", &n);
    map<int, int> x_axis, y_axis;
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &x[i], &y[i]);
        x_axis[x[i]]++;
        y_axis[y[i]]++;
    }
    long long ans = 0;
    for(int i = 0; i < n; i++) {
        ans += (x_axis[x[i]]-1)*(y_axis[y[i]]-1);
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:20:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   20 |     printf("%d\n", ans);
      |             ~^     ~~~
      |              |     |
      |              int   long long int
      |             %lld
triangle.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
triangle.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d %d", &x[i], &y[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 8 ms 952 KB Output is correct
13 Correct 9 ms 1052 KB Output is correct
14 Correct 12 ms 1380 KB Output is correct
15 Correct 121 ms 6168 KB Output is correct
16 Correct 135 ms 6352 KB Output is correct
17 Correct 120 ms 6084 KB Output is correct
18 Correct 127 ms 6120 KB Output is correct
19 Correct 396 ms 11476 KB Output is correct
20 Correct 256 ms 9172 KB Output is correct
21 Correct 366 ms 12164 KB Output is correct
22 Correct 392 ms 12164 KB Output is correct