Submission #675201

# Submission time Handle Problem Language Result Execution time Memory
675201 2022-12-27T02:53:19 Z vjudge1 Trampoline (info1cup20_trampoline) C++17
100 / 100
1871 ms 40216 KB
// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define pii pair<int,int>
const int mod=998244353;
const int maxn=200005;
const int maxl=20;
const int maxa=1000005;
int power(int a,int n){
    int res=1;
    while(n){
        if(n&1) res=res*a%mod;
        a=a*a%mod;n>>=1;
    }
    return res;
}
int r,c,n,nxt[maxn][maxl];
pii x[maxn];
map<int,vector<pii>> mp;
int cal(int p,int i){
    int cur=x[p].first+(1<<(i-1)),y=nxt[p][i-1];
    if(y==-1) return -1;
    auto it=lower_bound(mp[cur].begin(),mp[cur].end(),make_pair(y,0));
    if(it==mp[cur].end()) return -1;
    return nxt[it->second][i-1];
}
bool check(int x1,int y1,int x2,int y2){
    if(x1>x2) return false;
    if(x1==x2){
        if(y1<=y2) return true;
        else return false;
    }
    for(int i=0;i<18;i++){
        if((x2-x1)&(1<<i)){
            auto it=lower_bound(mp[x1].begin(),mp[x1].end(),make_pair(y1,0));
            if(it==mp[x1].end()) return false;
            y1=nxt[it->second][i];x1+=(1<<i);
        }
        if(y1==-1) return false;
    }
    if(y1<=y2) return true;
    else return false;
}
void solve(){
    int r,c,n;cin >> r >> c >> n;
    for(int i=1;i<=n;i++) cin >> x[i].first >> x[i].second;
    sort(x+1,x+n+1);
    for(int i=1;i<=n;i++){mp[x[i].first].push_back({x[i].second,i});nxt[i][0]=x[i].second;}
    for(int i=1;i<18;i++){
        for(int j=1;j<=n;j++) nxt[j][i]=cal(j,i);
    }
    int t;cin >> t;
    while(t--){
        int x1,y1,x2,y2;cin >> x1 >> y1 >> x2 >> y2;
        if(check(x1,y1,x2,y2)) cout << "Yes\n";
        else cout << "No\n";
    }
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t=1;//cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1108 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 1236 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 980 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 186 ms 20244 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 171 ms 20184 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 189 ms 19564 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 183 ms 20156 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 223 ms 20476 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 245 ms 20176 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 256 ms 19920 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 356 ms 20568 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 365 ms 20568 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 631 ms 26424 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 6 ms 852 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 828 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 10 ms 1720 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 5 ms 848 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 13 ms 980 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 1077 ms 27784 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 743 ms 22344 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 285 ms 20040 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1871 ms 40216 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 653 ms 27204 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 284 ms 20276 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 277 ms 20296 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 284 ms 19912 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1006 ms 26584 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1006 ms 26460 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1640 ms 32848 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 232 ms 19908 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 261 ms 20312 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 507 ms 20652 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 253 ms 20348 KB 200000 token(s): yes count is 129674, no count is 70326