Submission #982337

# Submission time Handle Problem Language Result Execution time Memory
982337 2024-05-14T06:56:31 Z Faisal_Saqib New Home (APIO18_new_home) C++17
5 / 100
5000 ms 42324 KB
#include <bits/stdc++.h>
using namespace std;
// struct store
// {
// 	int location,type,startingyear,endingyear;
// };
void solve()
{
	int n,k,q;
	cin>>n>>k>>q;
	vector<vector<int>> tp; 
	for(int i=0;i<n;i++)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		tp.push_back({a,b,c,d});
	}
	long long tn=n;
	long long tq=q;
	long long nn=2e8;
	while(q--)
	{
		int l,y;
		cin>>l>>y;
		set<int> typ,ind;
		for(int i=0;i<n;i++)
		{
			if(tp[i][2]<=y and y<=tp[i][3])
			{
				typ.insert(tp[i][1]);
				ind.insert(i);
			}
		}
		if(typ.size()!=k)
		{
			cout<<-1<<endl;
		}
		else
		{
			map<int,int> tpp;
			for(auto j:ind)
			{
				if(tpp.find(tp[j][1])==tpp.end())
				{
					tpp[tp[j][1]]=abs(l-tp[j][0]);
				}
				else
					tpp[tp[j][1]]=min(tpp[tp[j][1]],abs(l-tp[j][0]));
			}
			int ans=0;
			for(auto i:tpp)
				ans=max(ans,i.second);
			cout<<ans<<'\n';
		}
	}
}
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
	solve();
	return 0;
}

Compilation message

new_home.cpp: In function 'void solve()':
new_home.cpp:34:16: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   if(typ.size()!=k)
      |      ~~~~~~~~~~^~~
new_home.cpp:18:12: warning: unused variable 'tn' [-Wunused-variable]
   18 |  long long tn=n;
      |            ^~
new_home.cpp:19:12: warning: unused variable 'tq' [-Wunused-variable]
   19 |  long long tq=q;
      |            ^~
new_home.cpp:20:12: warning: unused variable 'nn' [-Wunused-variable]
   20 |  long long nn=2e8;
      |            ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 456 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 548 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 9 ms 348 KB Output is correct
16 Correct 13 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 9 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 344 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 456 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 548 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 9 ms 348 KB Output is correct
16 Correct 13 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 9 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 344 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Execution timed out 5016 ms 7908 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5055 ms 42324 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5038 ms 37328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 456 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 548 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 9 ms 348 KB Output is correct
16 Correct 13 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 9 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 344 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Execution timed out 5016 ms 7908 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 456 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 548 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 9 ms 348 KB Output is correct
16 Correct 13 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 9 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 344 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 14 ms 604 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Execution timed out 5016 ms 7908 KB Time limit exceeded
32 Halted 0 ms 0 KB -