답안 #1043369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043369 2024-08-04T08:53:06 Z vjudge1 새 집 (APIO18_new_home) C++17
0 / 100
5000 ms 175096 KB
#include <bits/stdc++.h>

using namespace std;

const int inf = 1e9;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
	
	int n,k,q;
	cin>>n>>k>>q;
	set<int> se;
	unordered_map<int,int> com;
	vector<vector<int>> ev,que;
	int t,a,s,e;
	for (int i=0;i<n;i++)
	{
		cin>>a>>t>>s>>e,t--;
		ev.push_back({s,e,a,t});
		se.insert(s),se.insert(e);
	}
	int ans[q]={};
	while (q--)
	{
		int l,y;
		cin>>l>>y;
		se.insert(y);
		que.push_back({y,l,(int)que.size()});
	}
	for (int i:se)
		com[i]=com.size();
	int m=com.size();
	vector<pair<int,int>> st[m],en[m],qu[m];
	for (auto i:ev)
	{
		st[com[i[0]]].push_back({i[2],i[3]});
		en[com[i[1]]].push_back({i[2],i[3]});
	}
	for (auto i:que)
		qu[com[i[0]]].push_back({i[1],i[2]});
	set<int> ms[k];
	for (int c=0;c<m;c++)
	{
		for (auto i:st[c])
			ms[i.second].insert(i.first);
		for (auto i:qu[c])
			for (t=0;t<k;t++)
			{
				if (ms[t].empty())
				{
					ans[i.second]=-1;
					break;
				}
				auto x=ms[t].lower_bound(i.first);
				int val=inf;
				if (x!=ms[t].end())
					val=*x-i.first;
				if (x!=ms[t].begin())
				{
					x--;
					val=min(val,i.first-*x);
				}
				ans[i.second]=max(ans[i.second],val);
			}
		for (auto i:en[c])
			ms[i.second].erase(i.first);
	}
	for (int i:ans)
		cout<<i<<' ';
	cout<<endl;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5033 ms 116460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5047 ms 175096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -