답안 #448083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448083 2021-07-28T18:10:45 Z cadmiumsky Trampoline (info1cup20_trampoline) C++14
100 / 100
1110 ms 28664 KB
#include <iostream>
#include <algorithm>

#define cell(x,y) kus(x,y)

using namespace std;

struct cell {
  int x,y;
  bool operator <(const cell a) const {
    return x<a.x || (a.x==x && y<a.y);
  }
} green[200001];
int n;

static cell kus(int x, int y) {
  cell rez;
  rez.x=x;
  rez.y=y;
  return rez;
}

static int findfirst(int x, int y) {
  cell val=cell(x,y);
  int temp,bound=-1;
  for(int i=(1<<17); i>0; i>>=1) {
    temp=min(n,bound+i);
    if(green[temp]<val)
      bound=temp;
  }
  return bound+1;
}

int st[200001][18];

int main() {
  int q,r,c;
  cin >> r >> c >> n;
  for(int i=0,a,b; i<n; i++) {
    cin >> a >> b;
    green[i]=cell(a,b);
  }
  green[n]=cell(r+1,c+1);
  sort(green,green+n);
  for(int i=0;i<n; i++) {
    st[i][0]=findfirst(green[i].x+1,green[i].y);
    if(green[st[i][0]].x!=green[i].x+1)
      st[i][0]=n;
  }
  st[n][0]=n;
  for(int step=1; step<18; step++) {
    for(int j=0; j<=n;j++) {
      st[j][step]=st[st[j][step-1]][step-1];
    }
  }
  
  cin >> q;
  
  for(int tc=0,x1,x2,y1,y2,diff,curr; tc<q; tc++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if(x2-x1>n || x2<x1 || y2<y1) 
      cout << "No\n";
    else if(x1==x2) { // wtfffffffff
      cout << "Yes\n";
    }
    else {
      diff=x2-x1-1;
      curr=findfirst(x1,y1);
      if(green[curr].x!=x1)
        cout << "No\n";
      else { 
        for(int i=0; i<18; i++) {
          if((1<<i)&diff)
            curr=st[curr][i];
        }
        //cout << green[curr].x <<' '<< green[curr].y <<'\n';
        cout << (green[curr].x+1==x2 && green[curr].y<=y2?"Yes\n":"No\n");
      }
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 972 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 1076 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 844 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 181 ms 15920 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 186 ms 15880 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 193 ms 15920 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 186 ms 16068 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 967 ms 16704 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 1016 ms 16660 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 973 ms 16612 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 944 ms 16588 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 937 ms 16584 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 980 ms 16712 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 716 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 23 ms 1004 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 24 ms 988 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 29 ms 984 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 23 ms 1000 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 23 ms 972 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 1084 ms 16692 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 1056 ms 16728 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 1004 ms 28268 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1078 ms 28240 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 1099 ms 28216 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 1038 ms 28424 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 991 ms 28324 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 987 ms 28408 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1100 ms 28328 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1096 ms 28304 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1110 ms 28176 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 944 ms 28424 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 984 ms 28300 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 1102 ms 28664 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 1002 ms 28448 KB 200000 token(s): yes count is 129674, no count is 70326