| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 59286 | Just_Solve_The_Problem | 새 집 (APIO18_new_home) | C++11 | 2780 ms | 118444 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
const int N = (int)3e5 + 7;
const int inf = (int)1e9 + 7;
int n, k, q;
int x[N], t[N], a[N], b[N];
multiset < int > s[404];
int ans[N];
struct query {
  int type, x, t, y, ind;
  query() {}
  query(int _type, int _x, int _t, int _y) {
    type = _type;
    x = _x;
    t = _t;
    y = _y;
  }
};
vector < query > vec;
bool cmp(query &A, query &B) {
  if (A.y != B.y)
    return A.y < B.y;
  return A.type < B.type;
}
main() {
	scanf("%d %d %d", &n, &k, &q);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d %d %d", &x[i], &t[i], &a[i], &b[i]);
    vec.pb(query(0, x[i], t[i], a[i]));
    vec.pb(query(1, x[i], t[i], b[i] + 1));
  }
  for (int i = 1, l, y; i <= q; i++) {
    scanf("%d %d", &l, &y);
    vec.pb(query(2, l, 0, y));
    vec.back().ind = i;
  }
  sort(all(vec), cmp);
  for (auto to : vec) {
    if (to.type == 0) {
      s[to.t].insert(to.x);
    } else if (to.type == 1) {
      s[to.t].erase(s[to.t].find(to.x));
    } else {
      int res = -1;
      for (int i = 1; i <= k; i++) {
        if (s[i].empty()) {
          res = -1;
          break;
        } else {
          auto it = s[i].lower_bound(to.x);
          int asd = inf;
          if (it != s[i].end())
            asd = min(asd, abs(to.x - (*it)));
          if (it != s[i].begin()) {
            it--;
            asd = min(asd, abs(to.x - (*it)));
          }
          res = max(res, asd);
        }
      }
      ans[to.ind] = res;
    }
  }
  for (int i = 1; i <= q; i++) {
    printf("%d\n", ans[i]);
  }
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
