Submission #1724967
Source Code Expand
#include <cstdio> #include <algorithm> using namespace std; #define fr first #define se second #define pr pair<int,int> #define mp make_pair #define N 300000 int n,m,i,j,mask,a[N],l[20][N],r[20][N],k,f[N<<1],g[N<<1],id; pr b[N<<1]; bool c[N]; int main() { scanf("%d%d",&n,&m); for (i=1;i<=n;i++) scanf("%d",&a[i]);int psz=0,jj=-1; for (j=m;j!=jj;jj=j,j>>=1){ int lst=1; for (i=2;i<=n;i++) if (a[i]-a[i-1]>j){ for (k=lst;k<i;k++) l[psz][k]=lst,r[psz][k]=i-1; lst=i; } for (k=lst;k<=n;k++) l[psz][k]=lst,r[psz][k]=n; psz++; } for (mask=0;mask<(1<<psz);mask++) for (i=0;i<psz;i++) if (!(mask&(1<<i))) f[mask|(1<<i)]=max(f[mask|(1<<i)],r[i][f[mask]+1]); for (mask=0;mask<(1<<psz);mask++) g[mask]=n+1; for (mask=0;mask<(1<<psz);mask++) for (i=0;i<psz;i++) if (!(mask&(1<<i))) g[mask|(1<<i)]=min(g[mask|(1<<i)],l[i][g[mask]-1]); for (mask=0;mask<(1<<psz);mask++) if (!(mask&1)) b[++id]=mp(g[mask],mask); for (i=1;i<=n;i++) b[++id]=mp(r[0][i]+1,i+(1<<psz)); sort(b+1,b+id+1);int wtf=-1; for (i=1;i<=id;i++) if (b[i].se>(1<<psz)){ b[i].se-=(1<<psz); if (wtf>=l[0][b[i].se]-1) c[b[i].se]=true; }else wtf=max(wtf,f[b[i].se^((1<<psz)-2)]); for (i=1;i<=n;i++) if (c[i]) puts("Possible");else puts("Impossible"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Camel and Oases |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1247 Byte |
Status | AC |
Exec Time | 159 ms |
Memory | 59392 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&m); ^ ./Main.cpp:15:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (i=1;i<=n;i++) scanf("%d",&a[i]);int psz=0,jj=-1; ^
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 | 4 ms | 14464 KB |
00_example_02.txt | AC | 3 ms | 14464 KB |
00_example_03.txt | AC | 4 ms | 22656 KB |
01.txt | AC | 105 ms | 57216 KB |
02.txt | AC | 31 ms | 47744 KB |
03.txt | AC | 104 ms | 57216 KB |
04.txt | AC | 31 ms | 47744 KB |
05.txt | AC | 104 ms | 57216 KB |
06.txt | AC | 127 ms | 57472 KB |
07.txt | AC | 39 ms | 48128 KB |
08.txt | AC | 123 ms | 57472 KB |
09.txt | AC | 39 ms | 48128 KB |
10.txt | AC | 107 ms | 57344 KB |
11.txt | AC | 67 ms | 50816 KB |
12.txt | AC | 105 ms | 57344 KB |
13.txt | AC | 158 ms | 59392 KB |
14.txt | AC | 103 ms | 57216 KB |
15.txt | AC | 31 ms | 47744 KB |
16.txt | AC | 103 ms | 57216 KB |
17.txt | AC | 31 ms | 47744 KB |
18.txt | AC | 104 ms | 57216 KB |
19.txt | AC | 54 ms | 50304 KB |
20.txt | AC | 125 ms | 57472 KB |
21.txt | AC | 35 ms | 48128 KB |
22.txt | AC | 124 ms | 57472 KB |
23.txt | AC | 37 ms | 48256 KB |
24.txt | AC | 106 ms | 57344 KB |
25.txt | AC | 59 ms | 50688 KB |
26.txt | AC | 124 ms | 57472 KB |
27.txt | AC | 159 ms | 59392 KB |
28.txt | AC | 110 ms | 57472 KB |
29.txt | AC | 39 ms | 48128 KB |
30.txt | AC | 125 ms | 57472 KB |
31.txt | AC | 66 ms | 50688 KB |
32.txt | AC | 107 ms | 57344 KB |
33.txt | AC | 67 ms | 50688 KB |
34.txt | AC | 108 ms | 57344 KB |
35.txt | AC | 155 ms | 59392 KB |
36.txt | AC | 104 ms | 57216 KB |
37.txt | AC | 31 ms | 47744 KB |
38.txt | AC | 104 ms | 57216 KB |
39.txt | AC | 30 ms | 47744 KB |
40.txt | AC | 104 ms | 57216 KB |
41.txt | AC | 55 ms | 50304 KB |
42.txt | AC | 103 ms | 57216 KB |
43.txt | AC | 54 ms | 50304 KB |
44.txt | AC | 104 ms | 57216 KB |
45.txt | AC | 54 ms | 50304 KB |
46.txt | AC | 35 ms | 48128 KB |
47.txt | AC | 107 ms | 57344 KB |
48.txt | AC | 57 ms | 50688 KB |
49.txt | AC | 123 ms | 57344 KB |
50.txt | AC | 57 ms | 50560 KB |
51.txt | AC | 105 ms | 57344 KB |
52.txt | AC | 57 ms | 50560 KB |
53.txt | AC | 122 ms | 57344 KB |
54.txt | AC | 58 ms | 50560 KB |
55.txt | AC | 107 ms | 57344 KB |
56.txt | AC | 38 ms | 48000 KB |
57.txt | AC | 107 ms | 57344 KB |
58.txt | AC | 58 ms | 50688 KB |
59.txt | AC | 105 ms | 57344 KB |
60.txt | AC | 58 ms | 50688 KB |
61.txt | AC | 108 ms | 57344 KB |
62.txt | AC | 66 ms | 50688 KB |
63.txt | AC | 108 ms | 57344 KB |
64.txt | AC | 58 ms | 50688 KB |
65.txt | AC | 108 ms | 57344 KB |
66.txt | AC | 3 ms | 14464 KB |
67.txt | AC | 3 ms | 14464 KB |