Google Kick Start 2021 Round G - B (Staying Hydrated)

Dongjae Lee·2021년 10월 20일
0
#include <bits/stdc++.h>
using namespace std;

int main() {
	int T;
	scanf("%d", &T);
	
	for(int tc = 1; tc <= T; tc++) {
		int K;
		scanf("%d", &K);
		
		map<long long, int> mx;
		map<long long, int> my;
		for(int i = 0; i < K; i++) {			
			long long x1, y1, x2, y2;
			scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
			
			mx[x1]++;
			mx[x2]++;
			
			my[y1]++;
			my[y2]++;
		}
		long long resultx, resulty;
		int count = -1*K;
		for(auto it = mx.begin(); it != mx.end(); it++) {
			count += it->second;
			if(count >= 0) {
				resultx = it->first;
				break;
			}
		}
		count = -1*K;
		for(auto it = my.begin(); it != my.end(); it++) {
			count += it->second;
			if(count >= 0) {
				resulty = it->first;
				break;
			}
		}
		printf("Case #%d: %lld %lld\n", tc, resultx, resulty);
	}
}
profile
Hello Everything!

0개의 댓글