답안 #992608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992608 2024-06-04T19:29:39 Z kachim2 Trampoline (info1cup20_trampoline) C++17
0 / 100
202 ms 62932 KB
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <valarray>
#include <variant>
using namespace std;

struct trampoline {
  long x, y;
  vector<trampoline *> jp;
  bool isjp = 0;
  friend bool operator<(const trampoline &l, const trampoline &r) {
    return l.x < r.x;
  }
  void genjp();
};
unordered_map<long, vector<trampoline>> trampolines;
void trampoline::genjp() {
  if (isjp)
    return;
  isjp = 1;
  trampoline *next;
  if (!trampolines.count(y + 1))
    return;

  auto &a = trampolines[y + 1];
  auto b = lower_bound(a.begin(), a.end(), *this);
  if (b == a.end()) {
    return;
  }
  next = &*b;

  jp.push_back(next);
  while (true) {
    (*jp.rbegin())->genjp();
    if (this->jp.size() > (*jp.rbegin())->jp.size()) {
      return;
    }
    jp.push_back((*jp.rbegin())->jp[this->jp.size() - 1]);
  }
}
int main() {
  int R, C, N;
  cin >> R >> C >> N;

  vector<trampoline *> tramps;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> y >> x;

    trampolines[y].push_back({.x = x, .y = y});
    tramps.push_back(&*trampolines[y].rbegin());
  }
  for (auto &[key, i] : trampolines) {
    sort(i.begin(), i.end());
  }
  for (auto i : tramps) {
    i->genjp();
  }
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    if(i!=0)cout << '\n';
    int x1, x2, y1, y2;
    cin >> y1 >> x1 >> y2 >> x2;
    if(y1 == y2 and x1 <= x2){
      cout << "Yes";
      continue;
    }
    trampoline tmptramp;
    tmptramp.x = x1;
    auto tc = lower_bound(trampolines[y1].begin(), trampolines[y1].begin(), tmptramp);
    if(tc == trampolines[y1].end()){
      cout << "No";
      continue;
      
    }
    trampoline *curr = &*tc;
    int v = y2-y1-1;
    for(int j = 0; v!=0; j++){
      if(v&1){
      if(curr->jp.size() <= j) goto no;
      curr = curr->jp[j];
      }
     v>>=1;
    }
    if(curr->x > x2){
      goto no;
    }
    goto yes;
  no:
    cout << "No";
    continue;
  yes:
    cout << "Yes";
  }

 
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:82:26: warning: comparison of integer expressions of different signedness: 'std::vector<trampoline*>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   82 |       if(curr->jp.size() <= j) goto no;
      |          ~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 2136 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 94 ms 39360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 133 ms 35316 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1624 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 202 ms 62932 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -