답안 #1009403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1009403 2024-06-27T13:21:23 Z 12345678 Trampoline (info1cup20_trampoline) C++17
100 / 100
655 ms 56400 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5, kx=18;

int r, c, n, q, p[4], pa[nx][kx], x[nx], y[nx];
map<int, set<pair<int, int>>> mp;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>r>>c>>n;
    for (int i=1; i<=n; i++) cin>>x[i]>>y[i], mp[x[i]].insert({y[i], i});
    for (int i=1; i<=n; i++) 
    {
        if (mp.find(x[i]+1)==mp.end()||mp[x[i]+1].lower_bound(make_pair(y[i], 0))==mp[x[i]+1].end()) pa[i][0]=i;
        else pa[i][0]=mp[x[i]+1].lower_bound(make_pair(y[i], 0))->second;
    }
    for (int i=1; i<kx; i++) for (int j=1; j<=n; j++) pa[j][i]=pa[pa[j][i-1]][i-1];
    cin>>q;
    while (q--)
    {
        cin>>p[0]>>p[1]>>p[2]>>p[3];
        if (p[0]>p[2]) cout<<"No\n";
        else if (p[1]>p[3]) cout<<"No\n";
        else if (p[0]==p[2]) cout<<"Yes\n";
        else if (mp.find(p[0])==mp.end()||mp[p[0]].lower_bound(make_pair(p[1], 0))==mp[p[0]].end()) cout<<"No\n";
        else
        {
            int st=mp[p[0]].lower_bound(make_pair(p[1], 0))->second;
            for (int i=kx-1; i>=0; i--) if (x[pa[st][i]]<p[2]) st=pa[st][i];
            if (x[st]!=p[2]-1) cout<<"No\n";
            else if (y[st]<=p[3]) cout<<"Yes\n";
            else cout<<"No\n";

        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2908 KB 200 token(s): yes count is 21, no count is 179
2 Correct 6 ms 5208 KB 200 token(s): yes count is 70, no count is 130
3 Correct 4 ms 2908 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 25912 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 191 ms 27496 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 179 ms 26920 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 221 ms 27408 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 344 ms 25952 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 347 ms 26064 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 351 ms 26020 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 422 ms 26196 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 386 ms 26304 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 473 ms 32248 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2776 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 5 ms 2652 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 6 ms 3256 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 5 ms 2908 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 9 ms 3164 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 8 ms 2908 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 546 ms 33716 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 512 ms 27892 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 368 ms 26052 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 655 ms 56400 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 494 ms 44368 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 393 ms 37968 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 425 ms 37724 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 380 ms 37860 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 529 ms 44112 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 549 ms 43924 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 603 ms 50136 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 270 ms 37716 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 303 ms 37712 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 410 ms 38088 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 363 ms 37820 KB 200000 token(s): yes count is 129674, no count is 70326