답안 #20815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20815 2017-02-16T09:06:00 Z jjwdi0 별들과 삼각형 (IZhO11_triangle) C++11
100 / 100
1293 ms 36344 KB
#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
using namespace std;

map<int, set<int>> s1, s2;
int N;
long long ans;

int main() {
	scanf("%d", &N);
	for(int i=0, x, y; i<N; i++) {
		scanf("%d %d", &x, &y);
		s1[x].insert(y);
		s2[y].insert(x);
	}
	for(auto itr : s1) {
        int i = itr.first;
		if(sz(s1[i]) >= 2) {
			for(auto it : s1[i]) {
				ans += (long long)(sz(s1[i]) - 1) * (sz(s2[it]) - 1);
			}
		}
	}
	printf("%lld", ans);
}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
triangle.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &x, &y);
                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Correct 0 ms 2024 KB Output is correct
4 Correct 0 ms 2024 KB Output is correct
5 Correct 0 ms 2024 KB Output is correct
6 Correct 0 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
8 Correct 0 ms 2024 KB Output is correct
9 Correct 0 ms 2156 KB Output is correct
10 Correct 0 ms 2156 KB Output is correct
11 Correct 0 ms 2288 KB Output is correct
12 Correct 9 ms 4004 KB Output is correct
13 Correct 13 ms 4136 KB Output is correct
14 Correct 19 ms 4532 KB Output is correct
15 Correct 323 ms 17204 KB Output is correct
16 Correct 356 ms 18128 KB Output is correct
17 Correct 353 ms 17336 KB Output is correct
18 Correct 353 ms 17204 KB Output is correct
19 Correct 1176 ms 34232 KB Output is correct
20 Correct 753 ms 26972 KB Output is correct
21 Correct 1186 ms 36344 KB Output is correct
22 Correct 1293 ms 36344 KB Output is correct