Submission #1726512
Source Code Expand
#include <cstdio> #include <algorithm> #define mp(x,y) make_pair(x,y) #define ft first #define sd second #define rep(i,l,r) for (int i=l;i<=r;++i) #define P pair<int ,int > using namespace std; const int N =2e5+10; void read(int &x) { x=0; char ch=getchar();int f=1; while (ch<'0'||ch>'9') ch=='-'?f=-1:0,ch=getchar(); while ('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar(); x*=f; } int n,bo[N],tot,m,a[N],top,v[233],l[N][20],r[N][20],f[1<<20],g[1<<20],cnt,tmp; P b[N<<1]; void _mx(int &x,int y) { x=max(x,y); } void _mn(int &x,int y) { x=min(x,y); } int main() { read(n);read(m); rep(i,1,n) read(a[i]); for (;v[top++]=m;m>>=1); rep(i,0,top) { int lst=1; rep(j,2,n) if (a[j]-a[j-1]>v[i]) { rep(k,lst,j-1) l[k][i]=lst,r[k][i]=j-1; lst=j; } rep(k,lst,n) l[k][i]=lst,r[k][i]=n; } tot=1<<top;--tot;rep(i,0,tot) g[i]=n+1; rep(i,0,tot) rep(j,0,top) if (!(i&1<<j)) _mx(f[i|1<<j] ,r[f[i]+1][j]),_mn(g[i|1<<j] ,l[g[i]-1][j]); rep(i,0,tot) if (!(i&1)) b[++cnt]=mp(g[i],i); rep(i,1,n) b[++cnt]=mp(r[i][0]+1,(1<<top)+i); sort(b+1,b+1+cnt);tmp=-1; rep(i,1,cnt) if (b[i].sd>(1<<top)) { b[i].sd-=(1<<top); if (tmp>=l[b[i].sd][0]-1) bo[b[i].sd]=1; }else _mx(tmp,f[((1<<top)-2)^b[i].sd]); rep(i,1,n) printf("%s\n",bo[i]?"Possible":"Impossible"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Camel and Oases |
User | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1286 Byte |
Status | AC |
Exec Time | 214 ms |
Memory | 45696 KB |
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 | 3 ms | 10368 KB |
00_example_02.txt | AC | 3 ms | 10368 KB |
00_example_03.txt | AC | 3 ms | 10368 KB |
01.txt | AC | 100 ms | 16512 KB |
02.txt | AC | 23 ms | 14976 KB |
03.txt | AC | 100 ms | 16512 KB |
04.txt | AC | 23 ms | 14976 KB |
05.txt | AC | 100 ms | 16512 KB |
06.txt | AC | 126 ms | 20992 KB |
07.txt | AC | 33 ms | 17408 KB |
08.txt | AC | 121 ms | 18816 KB |
09.txt | AC | 33 ms | 17536 KB |
10.txt | AC | 103 ms | 16640 KB |
11.txt | AC | 62 ms | 20096 KB |
12.txt | AC | 103 ms | 18688 KB |
13.txt | AC | 212 ms | 45696 KB |
14.txt | AC | 99 ms | 16512 KB |
15.txt | AC | 23 ms | 14976 KB |
16.txt | AC | 99 ms | 16512 KB |
17.txt | AC | 23 ms | 14976 KB |
18.txt | AC | 100 ms | 16512 KB |
19.txt | AC | 46 ms | 15488 KB |
20.txt | AC | 123 ms | 20992 KB |
21.txt | AC | 29 ms | 17408 KB |
22.txt | AC | 122 ms | 20864 KB |
23.txt | AC | 31 ms | 19584 KB |
24.txt | AC | 103 ms | 18688 KB |
25.txt | AC | 53 ms | 17920 KB |
26.txt | AC | 123 ms | 20864 KB |
27.txt | AC | 214 ms | 45696 KB |
28.txt | AC | 109 ms | 20864 KB |
29.txt | AC | 33 ms | 17408 KB |
30.txt | AC | 125 ms | 20864 KB |
31.txt | AC | 60 ms | 17920 KB |
32.txt | AC | 104 ms | 16640 KB |
33.txt | AC | 61 ms | 17920 KB |
34.txt | AC | 105 ms | 18816 KB |
35.txt | AC | 210 ms | 45696 KB |
36.txt | AC | 100 ms | 16512 KB |
37.txt | AC | 23 ms | 14976 KB |
38.txt | AC | 99 ms | 16512 KB |
39.txt | AC | 23 ms | 14976 KB |
40.txt | AC | 99 ms | 16512 KB |
41.txt | AC | 46 ms | 15488 KB |
42.txt | AC | 99 ms | 16512 KB |
43.txt | AC | 46 ms | 15488 KB |
44.txt | AC | 100 ms | 16512 KB |
45.txt | AC | 46 ms | 15488 KB |
46.txt | AC | 28 ms | 17408 KB |
47.txt | AC | 104 ms | 18816 KB |
48.txt | AC | 51 ms | 17920 KB |
49.txt | AC | 121 ms | 18816 KB |
50.txt | AC | 50 ms | 17792 KB |
51.txt | AC | 106 ms | 18688 KB |
52.txt | AC | 50 ms | 17792 KB |
53.txt | AC | 119 ms | 18688 KB |
54.txt | AC | 51 ms | 17792 KB |
55.txt | AC | 104 ms | 18816 KB |
56.txt | AC | 31 ms | 17280 KB |
57.txt | AC | 104 ms | 18816 KB |
58.txt | AC | 51 ms | 17920 KB |
59.txt | AC | 102 ms | 16640 KB |
60.txt | AC | 52 ms | 17920 KB |
61.txt | AC | 105 ms | 18816 KB |
62.txt | AC | 59 ms | 17920 KB |
63.txt | AC | 105 ms | 18816 KB |
64.txt | AC | 51 ms | 17920 KB |
65.txt | AC | 105 ms | 18816 KB |
66.txt | AC | 3 ms | 10368 KB |
67.txt | AC | 2 ms | 10368 KB |