Submission #675202

# Submission time Handle Problem Language Result Execution time Memory
675202 2022-12-27T02:53:45 Z vjudge1 Trampoline (info1cup20_trampoline) C++17
30 / 100
668 ms 39400 KB
#include<bits/stdc++.h>
using namespace std;
 
#define f first
#define s second
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> pt;
 
int r, c, n, t;
 
const int maxn = 2e5+5;
 
const ll inf = 1e9+5;

map<int, vector<pair<int, int>>> mp;
int dd[maxn];

int sp[20][maxn];

void build(){
    for(int i = 1; i < 20; i++){
        for(int j = 1; j <= n; j++){
            sp[i][j] = sp[i-1][sp[i-1][j]];
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++){
        int a, b;
        cin >> a >> b;
        mp[a].push_back({b, i});
        dd[i]=b;
    }
    for(auto it = mp.begin(); it != mp.end(); it++){
        sort(it->s.begin(), it->s.end());
    }
    for(auto v: mp){
        for(auto x: v.s){
            int pos = lower_bound(mp[v.f+1].begin(), mp[v.f+1].end(), make_pair(x.f, 0))-mp[v.f+1].begin();
            if(pos < mp[v.f+1].size())sp[0][x.s] = mp[v.f+1][pos].s;
        }
    }
    build();
    cin >> t;
    while(t--){
        int xs, ys, xt, yt;
        cin >> xs >> ys >> xt >> yt;
        if(ys > yt || xs > xt || xt - xs > n){
            cout << "No\n";
            continue;
        }
        if(xs == xt){
            cout << "Yes\n";
            continue;
        }
        int pos = lower_bound(mp[xs].begin(), mp[xs].end(), make_pair(ys, 0))-mp[xs].begin();
        if(pos == mp[xs].size())cout << "No\n";
        else{
            int crr = mp[xs][pos].s;
            for(int i = 0; i < 20; i++){
                if((1<<i)&(xt-xs-1))crr = sp[i][crr];
            }
            if(dd[crr] <= yt)cout << "Yes\n";
            else cout << "No\n";
        }
    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             if(pos < mp[v.f+1].size())sp[0][x.s] = mp[v.f+1][pos].s;
      |                ~~~~^~~~~~~~~~~~~~~~~~
trampoline.cpp:64:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         if(pos == mp[xs].size())cout << "No\n";
      |            ~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1236 KB expected NO, found YES [3rd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 19844 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 19960 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 178 ms 19936 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 184 ms 19628 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 231 ms 20172 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 230 ms 20164 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 381 ms 25956 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 5 ms 960 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 5 ms 852 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 11 ms 1768 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 4 ms 852 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 7 ms 1020 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 5 ms 852 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 532 ms 27256 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 409 ms 22196 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 190 ms 19656 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 668 ms 39400 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 355 ms 26372 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 204 ms 20064 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 200 ms 20248 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 183 ms 19572 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 491 ms 26160 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 513 ms 26220 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 606 ms 32232 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 171 ms 19608 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 173 ms 19612 KB 200000 token(s): yes count is 126733, no count is 73267
14 Incorrect 261 ms 20132 KB expected NO, found YES [36443rd token]
15 Halted 0 ms 0 KB -