Submission #982330

# Submission time Handle Problem Language Result Execution time Memory
982330 2024-05-14T06:46:42 Z Jawad_Akbar_JJ Circle selection (APIO18_circle_selection) C++17
0 / 100
66 ms 8136 KB
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;
const int N = 6e4 + 10;
int x[N], t[N], a[N], b[N], l[N], y[N], Ans[N];
multiset<int> loc[405];

int main(){
	int n,k,q;
	cin>>n>>k>>q;

	vector<pair<int,int>> tm;

	for (int i=1;i<=n;i++){
		cin>>x[i]>>t[i]>>a[i]>>b[i];
		tm.push_back({a[i],i});
	}

	sort(begin(tm),end(tm));

	vector<pair<int,int>> Q;

	for (int i=1;i<=q;i++){
		cin>>l[i]>>y[i];
		Q.push_back({y[i],i});
	}

	sort(begin(Q),end(Q));

	int tmi = 0;

	set<pair<int,int>> ert;

	for (auto [year,ind] : Q){
		while (tmi < n and tm[tmi].first <= year){
			int I = tm[tmi].second;
			tmi++;
			ert.insert({b[I],I});
			loc[t[I]].insert(x[I]);
		}
		while (ert.size() > 0 and (*begin(ert)).first < year){
			int I = (*begin(ert)).second;
			ert.erase(begin(ert));
			loc[t[I]].erase(loc[t[I]].find(x[I]));
		}

		int ans = 0;

		for (int i=1;i<=k;i++){
			if (loc[i].size() == 0){
				ans = -1;
				break;
			}
			int nans = 1e9;
			auto u = loc[i].upper_bound(l[ind]-1);
			if (u != loc[i].end())
				nans = min(nans,*u - l[ind]);
			if (u != loc[i].begin())
				nans = min(nans,l[ind] - *prev(u));
			ans = max(ans,nans);
		}
		Ans[ind] = ans;
	}

	for (int i=1;i<=q;i++)
		cout<<Ans[i]<<'\n';
}

# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 8136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 3640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 7108 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 66 ms 3528 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 8136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 8136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -