Submission #982335

# Submission time Handle Problem Language Result Execution time Memory
982335 2024-05-14T06:55:28 Z Faisal_Saqib New Home (APIO18_new_home) C++17
5 / 100
100 ms 29064 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;
	if((tn*tq)<=nn)
	{
		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<<endl;
			}
		}
	}
	else
	{

	}
}
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:36:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |    if(typ.size()!=k)
      |       ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 460 KB Output is correct
6 Correct 7 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 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 10 ms 348 KB Output is correct
16 Correct 14 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 13 ms 348 KB Output is correct
24 Correct 12 ms 344 KB Output is correct
25 Correct 5 ms 600 KB Output is correct
26 Correct 2 ms 500 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 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 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 460 KB Output is correct
6 Correct 7 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 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 10 ms 348 KB Output is correct
16 Correct 14 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 13 ms 348 KB Output is correct
24 Correct 12 ms 344 KB Output is correct
25 Correct 5 ms 600 KB Output is correct
26 Correct 2 ms 500 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Incorrect 19 ms 5648 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 28812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 29064 KB Output isn't correct
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 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 460 KB Output is correct
6 Correct 7 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 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 10 ms 348 KB Output is correct
16 Correct 14 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 13 ms 348 KB Output is correct
24 Correct 12 ms 344 KB Output is correct
25 Correct 5 ms 600 KB Output is correct
26 Correct 2 ms 500 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Incorrect 19 ms 5648 KB Output isn't correct
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 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 460 KB Output is correct
6 Correct 7 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 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 10 ms 348 KB Output is correct
16 Correct 14 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 10 ms 348 KB Output is correct
19 Correct 12 ms 348 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 27 ms 348 KB Output is correct
22 Correct 15 ms 600 KB Output is correct
23 Correct 13 ms 348 KB Output is correct
24 Correct 12 ms 344 KB Output is correct
25 Correct 5 ms 600 KB Output is correct
26 Correct 2 ms 500 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Incorrect 19 ms 5648 KB Output isn't correct
32 Halted 0 ms 0 KB -