# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
369976 | 2021-02-22T20:28:08 Z | A_D | Trampoline (info1cup20_trampoline) | C++14 | 763 ms | 82568 KB |
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second #define du long double using namespace std; const int N=4e5+1000; const int l=20; int nxt[N][l]; vector<ii> vec; set<ii> st; main() { int r,c,n; cin>>r>>c>>n; for(int i=1;i<=n;i++){ int a,b; scanf("%lld",&a); scanf("%lld",&b); vec.push_back({a,b}); vec.push_back({a+1,b}); st.insert({a,b}); } sort(vec.begin(),vec.end()); int sz=vec.size(); for(int i=0;i<l;i++)nxt[sz][i]=sz; int nx=sz; for(int i=sz-1;i>=0;i--){ int a=vec[i].F; int b=vec[i].S; if(i==sz-1||vec[i].F!=vec[i+1].F){ nx=sz; } if(st.find({a,b})!=st.end())nx=lower_bound(vec.begin(),vec.end(),make_pair(a+1,b))-vec.begin(); nxt[i][0]=nx; } // cout<<0<<endl; for(int j=1;j<l;j++){ for(int i=0;i<sz;i++){ nxt[i][j]=nxt[nxt[i][j-1]][j-1]; } } vec.push_back({1e10,1e10}); /* for(int i=0;i<vec.size();i++)cout<<i<<" "<<vec[i].F<<" "<<vec[i].S<<endl; cout<<endl; for(int i=0;i<sz;i++){ for(int j=0;j<l;j++){ cout<<nxt[i][j]<<" "; } cout<<endl; }*/ int t; cin>>t; while(t--){ int x1,x2,y1,y2; scanf("%lld",&x1); scanf("%lld",&y1); scanf("%lld",&x2); scanf("%lld",&y2); if(y2<y1||x2<x1){ printf("No\n"); continue; } int i=lower_bound(vec.begin(),vec.end(),make_pair(x1,y1))-vec.begin(); // cout<<i<<endl; for(int j=l-1;j>=0;j--){ if(((x2-x1)&(1<<j))){ if(i != sz) i = nxt[i][j]; // cout<<i<<endl; } } // cout<<vec[i].F<<" "<<vec[i].S<<endl; if(vec[i].S<=y2){ printf("Yes\n"); continue; } printf("No\n"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 3940 KB | 200 token(s): yes count is 21, no count is 179 |
2 | Correct | 13 ms | 4364 KB | 200 token(s): yes count is 70, no count is 130 |
3 | Correct | 9 ms | 3176 KB | 197 token(s): yes count is 25, no count is 172 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 422 ms | 82004 KB | 4000 token(s): yes count is 99, no count is 3901 |
2 | Correct | 428 ms | 81844 KB | 4000 token(s): yes count is 91, no count is 3909 |
3 | Correct | 447 ms | 81884 KB | 4000 token(s): yes count is 4000, no count is 0 |
4 | Correct | 445 ms | 81880 KB | 4000 token(s): yes count is 1991, no count is 2009 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 625 ms | 82504 KB | expected NO, found YES [5147th token] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 2408 KB | expected YES, found NO [355th token] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 763 ms | 82568 KB | expected YES, found NO [27361st token] |
2 | Halted | 0 ms | 0 KB | - |