답안 #1112582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112582 2024-11-14T11:03:24 Z Chinguun 별들과 삼각형 (IZhO11_triangle) C++14
0 / 100
1 ms 592 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ff first
#define ss second
#define pb push_back

const int N = 2e5 + 7;
const int oo = 1e18;
const int mod = 1e9 + 7;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

int n, x, y, ans;
map <int, vi> mp;
pii p[N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x >> y;
		mp[x].pb (y);
		p[y].ff++;
	}
	for (auto it : mp) {
		vi v = it.ss;
		for (int i = 0; i < v.size (); i++) {
			ans += i * (p[v[i]].ss + p[v[i]].ff - 1);
			ans += (v.size () - i - 1) * (p[v[i]].ss + p[v[i]].ff - 1);
			p[v[i]].ff--; p[v[i]].ss++;
		}
	}
	cout << ans;
	return 0;
}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:33:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int i = 0; i < v.size (); i++) {
      |                   ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -