Submission #19026095
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define x first
#define y second
#define bg begin()
#define ed end()
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define R(i,n) for(int i(0);i<(n);++i)
#define L(i,n) for(int i((n)-1);i>=0;--i)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;
//Data
const int N=2e5,D=21;
int n,m,a[N],fl[1<<D],fr[1<<D],sr[D][N],sl[D][N];
//Main
int main(){
// freopen("AGC012E.txt","r",stdin);
// freopen("yasdf2.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>m;
R(i,n) cin>>a[i];
int cnt=0,log_m=2,now=1;
for(;(now<<1)<=m;now<<=1,++log_m);
// cout<<"log_m="<<log_m<<'\n';
for(int l=0,r=0;l<n;++cnt,r=l=r+1)
for(;r+1<n&&a[r+1]-a[r]<=m;++r);
if(cnt>log_m){
// cout<<"payixiajiuzhanqilaile,henkuaia!\n";
R(i,n) cout<<"Impossible\n";
return 0;
}
for(int t=m,d=0;t>=0;t>>=1,++d){
for(int l=0,r=0;l<n;r=l=r+1){
for(;r+1<n&&a[r+1]-a[r]<=t;++r);
for(int t=l;t<=r;++t) sl[d][t]=l,sr[d][t]=r;
}
if(t==0) break;
}
R(s,1<<log_m) fr[s]=-1,fl[s]=n;
R(s,1<<log_m){
R(i,log_m)if(!(s>>i&1))
fr[s|1<<i]=max(fr[s|1<<i],sr[i][fr[s]+1]),
fl[s|1<<i]=min(fl[s|1<<i],sl[i][fl[s]-1]);
}
// R(s,1<<log_m) cout<<"s="<<s<<" fr="
// <<fr[s]<<" fl="<<fl[s]<<'\n';
for(int l=0,r=0;l<n;r=l=r+1){
for(;r+1<n&&a[r+1]-a[r]<=m;++r);
bool poss=false;
R(s,1<<log_m)if(!(s&1)&&fr[s]>=l-1
&&fl[((1<<log_m)-2)^s]<=r+1){poss=true; break;}
R(t,r-l+1) cout<<string(poss?"P":"Imp")+"ossible\n";
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Camel and Oases |
| User | George1123 |
| Language | C++ (GCC 9.2.1) |
| Score | 1000 |
| Code Size | 1818 Byte |
| Status | AC |
| Exec Time | 114 ms |
| Memory | 38124 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
| All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_example_01.txt | AC | 9 ms | 3548 KiB |
| 00_example_02.txt | AC | 3 ms | 3548 KiB |
| 00_example_03.txt | AC | 2 ms | 3568 KiB |
| 01.txt | AC | 60 ms | 7808 KiB |
| 02.txt | AC | 25 ms | 4764 KiB |
| 03.txt | AC | 60 ms | 7892 KiB |
| 04.txt | AC | 17 ms | 4820 KiB |
| 05.txt | AC | 55 ms | 7736 KiB |
| 06.txt | AC | 69 ms | 12396 KiB |
| 07.txt | AC | 27 ms | 7240 KiB |
| 08.txt | AC | 69 ms | 10764 KiB |
| 09.txt | AC | 22 ms | 7612 KiB |
| 10.txt | AC | 62 ms | 9304 KiB |
| 11.txt | AC | 42 ms | 9124 KiB |
| 12.txt | AC | 65 ms | 9620 KiB |
| 13.txt | AC | 111 ms | 38080 KiB |
| 14.txt | AC | 65 ms | 7860 KiB |
| 15.txt | AC | 20 ms | 4708 KiB |
| 16.txt | AC | 60 ms | 7816 KiB |
| 17.txt | AC | 14 ms | 4680 KiB |
| 18.txt | AC | 53 ms | 7728 KiB |
| 19.txt | AC | 31 ms | 5624 KiB |
| 20.txt | AC | 74 ms | 11840 KiB |
| 21.txt | AC | 30 ms | 7452 KiB |
| 22.txt | AC | 68 ms | 11236 KiB |
| 23.txt | AC | 30 ms | 8052 KiB |
| 24.txt | AC | 54 ms | 9668 KiB |
| 25.txt | AC | 43 ms | 8728 KiB |
| 26.txt | AC | 63 ms | 11320 KiB |
| 27.txt | AC | 110 ms | 38124 KiB |
| 28.txt | AC | 71 ms | 11620 KiB |
| 29.txt | AC | 28 ms | 6948 KiB |
| 30.txt | AC | 69 ms | 11520 KiB |
| 31.txt | AC | 42 ms | 8004 KiB |
| 32.txt | AC | 64 ms | 9620 KiB |
| 33.txt | AC | 47 ms | 8388 KiB |
| 34.txt | AC | 67 ms | 10508 KiB |
| 35.txt | AC | 114 ms | 38044 KiB |
| 36.txt | AC | 62 ms | 7844 KiB |
| 37.txt | AC | 25 ms | 4596 KiB |
| 38.txt | AC | 61 ms | 7868 KiB |
| 39.txt | AC | 25 ms | 4712 KiB |
| 40.txt | AC | 52 ms | 7832 KiB |
| 41.txt | AC | 37 ms | 5788 KiB |
| 42.txt | AC | 52 ms | 7724 KiB |
| 43.txt | AC | 39 ms | 5740 KiB |
| 44.txt | AC | 60 ms | 7816 KiB |
| 45.txt | AC | 37 ms | 5760 KiB |
| 46.txt | AC | 29 ms | 6908 KiB |
| 47.txt | AC | 69 ms | 10496 KiB |
| 48.txt | AC | 44 ms | 8052 KiB |
| 49.txt | AC | 58 ms | 10404 KiB |
| 50.txt | AC | 43 ms | 7788 KiB |
| 51.txt | AC | 67 ms | 9888 KiB |
| 52.txt | AC | 43 ms | 7772 KiB |
| 53.txt | AC | 74 ms | 10176 KiB |
| 54.txt | AC | 40 ms | 7780 KiB |
| 55.txt | AC | 69 ms | 10584 KiB |
| 56.txt | AC | 21 ms | 6424 KiB |
| 57.txt | AC | 58 ms | 10388 KiB |
| 58.txt | AC | 44 ms | 8140 KiB |
| 59.txt | AC | 58 ms | 9536 KiB |
| 60.txt | AC | 42 ms | 8292 KiB |
| 61.txt | AC | 66 ms | 10400 KiB |
| 62.txt | AC | 43 ms | 8016 KiB |
| 63.txt | AC | 68 ms | 10372 KiB |
| 64.txt | AC | 41 ms | 8204 KiB |
| 65.txt | AC | 68 ms | 10452 KiB |
| 66.txt | AC | 2 ms | 3504 KiB |
| 67.txt | AC | 2 ms | 3608 KiB |