#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define tol(bi) (1LL<<((int)(bi)))
#define endl '\n'
#define int long long
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
int32_t main(){
int T = 1;
int tno = 0;
while (T-(tno++)){
deci(n);deci(q);deci(k);
vector<array<int,4>> qu;
vector<multiset<int>> arr(k);
for (int i = 0; i < n; ++i)
{
deci(x);deci(t);deci(a);deci(b);
qu.push_back({a,t,x,1});
qu.push_back({b+1,x,t,-1});
}
sortarr(qu);
int indi = 0;
vector<array<int,3>> qarr;
for (int i = 0; i < q; i++){
deci(x);deci(t);
qarr.push_back({t,x,i});
}
vector<int> ansarr(q);
sortarr(qarr);
for (int i = 0; i < qarr.size(); ++i)
{
while (indi<qu.size() && qu[indi][0]<=qarr[i][0]){
if (qu[indi][3]==1){
arr[qu[indi][1]].insert(qu[indi][2]);
}
else {
arr[qu[indi][1]].erase(arr[qu[indi][1]].find(qu[indi][2]));
}
indi++;
}
int pos = qarr[i][1];
int ans = -1;
for (int i = 0; i < k; i++){
if (arr[i].size()==0) continue;
auto it = arr[i].lower_bound(pos);
int crr = LONG_LONG_MAX;
if (it!=arr[i].end()) crr=min(crr,(*it)-pos);
if (it!=arr[i].begin()){
it--;
crr=min(crr,pos-(*it));
}
}
ansarr[qarr[i][2]]=ans;
}
for (int i = 0; i < ansarr.size(); ++i)
{
cout<<ansarr[i]<<endl;
}
}
}
Compilation message
new_home.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim")
|
new_home.cpp: In function 'int32_t main()':
new_home.cpp:47:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for (int i = 0; i < qarr.size(); ++i)
| ~~^~~~~~~~~~~~~
new_home.cpp:49:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 4> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | while (indi<qu.size() && qu[indi][0]<=qarr[i][0]){
| ~~~~^~~~~~~~~~
new_home.cpp:72:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for (int i = 0; i < ansarr.size(); ++i)
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
405 ms |
49324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
395 ms |
96044 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |