Submission #2196858
Source Code Expand
#include<bits/stdc++.h> #define rep(i,x,y) for (int i=(x); i<=(y); i++) #define per(i,x,y) for (int i=(x); i>=(y); i--) #define N 1048576 #define ll long long using namespace std; int n,m,cnt,a[N],b[109],l[20][N],r[20][N],f[N],g[N]; struct node{ int x,y; node(){} node(int a,int b){ x=a,y=b; } }c[N]; const bool cmp(const node &x,const node &y){ return x.y<y.y; } int main(){ scanf("%d%d",&n,&m); for (; m; m>>=1) b[++cnt]=m; b[++cnt]=0; rep (i,1,cnt>>1) swap(b[i],b[cnt-i+1]); m=1<<cnt-1; rep (i,1,n) scanf("%d",&a[i]); rep (i,1,cnt){//预处理l[i][j]和r[i][j]表示第i层第j个点所在线段的左右端点 l[i][1]=1; r[i][n]=n; rep (j,2,n) l[i][j]=a[j]-a[j-1]<=b[i]?l[i][j-1]:j; per (j,n-1,1) r[i][j]=a[j+1]-a[j]<=b[i]?r[i][j+1]:j; } rep (i,0,m-1) g[i]=n+1,f[i]=0;//f[i]表示状态为i,从1开始延伸出去的最远长度;g[i]表示从n开始延伸的最远长度 //状态s的意思是,如果某位为1则表示当前层选了线段 rep (i,1,m-1) rep (j,1,cnt-1) if ((i>>j-1)&1){ int k=i^1<<j-1;//f[k]->f[i] f[i]=max(f[i],f[k]<n?r[j][f[k]+1]:n); g[i]=min(g[i],g[k]>1?l[j][g[k]-1]:1); } rep (i,0,m-1) if (f[i]+1<g[m-1^i]) c[i+1]=node(f[i]+1,g[m-1^i]-1); else{ rep(j,1,n) puts("Possible"); return 0; } sort(c+1,c+1+m,cmp); for (int i=1,j=1,k=0; i<=n; i++){ while (j<=m && c[j].y<=r[cnt][i]){ j++; k=max(k,c[j].x); } if (k>=l[cnt][i]) puts("Possible"); else puts("Impossible"); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Camel and Oases |
User | fengyuan |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1491 Byte |
Status | WA |
Exec Time | 111 ms |
Memory | 90496 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:11: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:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] rep (i,1,n) scanf("%d",&a[i]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 5 ms | 18688 KB |
00_example_02.txt | AC | 5 ms | 18688 KB |
00_example_03.txt | AC | 7 ms | 30976 KB |
01.txt | AC | 68 ms | 88320 KB |
02.txt | AC | 28 ms | 76544 KB |
03.txt | AC | 68 ms | 88320 KB |
04.txt | AC | 27 ms | 76544 KB |
05.txt | AC | 68 ms | 88320 KB |
06.txt | AC | 74 ms | 88576 KB |
07.txt | AC | 31 ms | 76672 KB |
08.txt | AC | 72 ms | 88448 KB |
09.txt | AC | 32 ms | 76800 KB |
10.txt | AC | 70 ms | 88448 KB |
11.txt | AC | 45 ms | 81408 KB |
12.txt | AC | 73 ms | 88448 KB |
13.txt | AC | 111 ms | 90496 KB |
14.txt | WA | 69 ms | 88320 KB |
15.txt | AC | 28 ms | 76544 KB |
16.txt | WA | 69 ms | 88320 KB |
17.txt | AC | 24 ms | 76032 KB |
18.txt | AC | 56 ms | 84224 KB |
19.txt | AC | 41 ms | 81152 KB |
20.txt | AC | 75 ms | 88576 KB |
21.txt | AC | 31 ms | 76672 KB |
22.txt | AC | 73 ms | 88576 KB |
23.txt | AC | 32 ms | 76800 KB |
24.txt | AC | 57 ms | 84352 KB |
25.txt | AC | 45 ms | 81408 KB |
26.txt | AC | 72 ms | 88576 KB |
27.txt | AC | 109 ms | 90496 KB |
28.txt | AC | 73 ms | 88576 KB |
29.txt | AC | 30 ms | 76672 KB |
30.txt | AC | 73 ms | 88576 KB |
31.txt | AC | 44 ms | 81280 KB |
32.txt | AC | 70 ms | 88448 KB |
33.txt | AC | 44 ms | 81408 KB |
34.txt | AC | 71 ms | 88448 KB |
35.txt | AC | 109 ms | 90496 KB |
36.txt | WA | 70 ms | 88320 KB |
37.txt | AC | 28 ms | 76544 KB |
38.txt | AC | 70 ms | 88320 KB |
39.txt | AC | 28 ms | 76544 KB |
40.txt | AC | 56 ms | 84224 KB |
41.txt | AC | 41 ms | 81152 KB |
42.txt | AC | 56 ms | 84224 KB |
43.txt | AC | 43 ms | 81152 KB |
44.txt | AC | 69 ms | 88320 KB |
45.txt | WA | 42 ms | 81152 KB |
46.txt | AC | 30 ms | 76672 KB |
47.txt | AC | 72 ms | 88448 KB |
48.txt | AC | 44 ms | 81280 KB |
49.txt | WA | 72 ms | 88448 KB |
50.txt | AC | 43 ms | 81280 KB |
51.txt | AC | 72 ms | 88448 KB |
52.txt | WA | 44 ms | 81280 KB |
53.txt | AC | 71 ms | 88448 KB |
54.txt | AC | 44 ms | 81280 KB |
55.txt | AC | 72 ms | 88448 KB |
56.txt | WA | 30 ms | 76672 KB |
57.txt | AC | 58 ms | 84352 KB |
58.txt | WA | 44 ms | 81280 KB |
59.txt | WA | 71 ms | 88448 KB |
60.txt | AC | 44 ms | 81280 KB |
61.txt | AC | 72 ms | 88448 KB |
62.txt | WA | 44 ms | 81280 KB |
63.txt | AC | 71 ms | 88448 KB |
64.txt | WA | 44 ms | 81280 KB |
65.txt | AC | 72 ms | 88448 KB |
66.txt | AC | 5 ms | 18688 KB |
67.txt | AC | 5 ms | 18688 KB |