이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
int main(){
int nums, types, queries; cin >> nums >> types >> queries;
vector<ll> loc(nums), typ(nums);
vector<multiset<ll>> vloc(types + 1);
for (int t = 1; t <= types; t++){
vloc[t].insert(-inf); vloc[t].insert(inf);
}
vector<tuple<ll, int, bool>> events;
for (int i = 0; i < nums; i++){
ll a, b; cin >> loc[i] >> typ[i] >> a >> b;
events.push_back({a, i, 1});
events.push_back({b + 1, i, 0});
}
sort(events.begin(), events.end());
vector<tuple<ll, ll, int>> qlist(queries);
vector<ll> ans(queries);
for (int q = 0; q < queries; q++){
ll l, y; cin >> l >> y;
qlist[q] = {y, l, q};
}
sort(qlist.begin(), qlist.end());
int curr = 0;
for (auto &[y, x, q] : qlist){
while (curr != events.size() && get<0>(events[curr]) <= y){
ll yr; int ind; bool b; tie(yr, ind, b) = events[curr]; curr++;
if (b) vloc[typ[ind]].insert(loc[ind]);
else vloc[typ[ind]].erase(vloc[typ[ind]].find(loc[ind]));
}
ll res = 0;
for (int t = 1; t <= types; t++){
if (vloc[t].size() == 2){
res = -1;
break;
}
auto it = vloc[t].lower_bound(x);
res = max(res, min(*it - x, x - *prev(it)));
}
ans[q] = res;
}
for (ll x : ans) cout << x << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
new_home.cpp: In function 'int main()':
new_home.cpp:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<long long int, int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | while (curr != events.size() && get<0>(events[curr]) <= y){
| ~~~~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |