답안 #679623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679623 2023-01-08T17:13:59 Z heeheeheehaaw Trampoline (info1cup20_trampoline) C++17
100 / 100
995 ms 28436 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) {
      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+1==x2 && green[curr].y<=y2?"Yes\n":"No\n");
      }
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1000 KB 200 token(s): yes count is 21, no count is 179
2 Correct 8 ms 1044 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 852 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 17780 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 151 ms 17720 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 140 ms 17404 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 178 ms 17840 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 777 ms 28412 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 748 ms 28332 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 762 ms 28236 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 763 ms 28284 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 818 ms 28324 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 797 ms 28152 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 980 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 24 ms 1012 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 19 ms 980 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 21 ms 940 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 21 ms 1004 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 24 ms 1008 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 967 ms 28240 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 967 ms 28308 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 883 ms 28388 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 995 ms 28224 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 981 ms 28176 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 939 ms 28424 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 879 ms 28288 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 982 ms 28296 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 842 ms 28232 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 887 ms 28224 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 913 ms 28336 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 758 ms 28428 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 772 ms 28436 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 830 ms 28408 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 800 ms 28412 KB 200000 token(s): yes count is 129674, no count is 70326