Submission #2196844
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 131072
#define ll long long
using namespace std;
int n,m,cnt,a[N],b[20],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]-1) 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);
//rep (i,1,m) printf("%d %d\n",c[i].x,c[i].y);
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);
}
//printf("%d\n",k);
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 |
1563 Byte |
Status |
RE |
Exec Time |
2103 ms |
Memory |
23296 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 |
|
AC |
× 22 |
WA |
× 45 |
TLE |
× 1 |
RE |
× 2 |
|
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 |
2 ms |
4352 KB |
00_example_02.txt |
AC |
2 ms |
4352 KB |
00_example_03.txt |
AC |
3 ms |
8448 KB |
01.txt |
WA |
29 ms |
21760 KB |
02.txt |
AC |
15 ms |
21760 KB |
03.txt |
WA |
30 ms |
21760 KB |
04.txt |
AC |
15 ms |
21760 KB |
05.txt |
WA |
29 ms |
21760 KB |
06.txt |
WA |
36 ms |
22144 KB |
07.txt |
AC |
18 ms |
22016 KB |
08.txt |
WA |
33 ms |
22016 KB |
09.txt |
AC |
19 ms |
22016 KB |
10.txt |
WA |
31 ms |
21888 KB |
11.txt |
WA |
30 ms |
23040 KB |
12.txt |
WA |
32 ms |
21888 KB |
13.txt |
RE |
115 ms |
768 KB |
14.txt |
WA |
30 ms |
21760 KB |
15.txt |
AC |
15 ms |
21760 KB |
16.txt |
WA |
30 ms |
21760 KB |
17.txt |
AC |
12 ms |
21248 KB |
18.txt |
AC |
30 ms |
21760 KB |
19.txt |
WA |
26 ms |
22784 KB |
20.txt |
WA |
34 ms |
22016 KB |
21.txt |
AC |
18 ms |
22016 KB |
22.txt |
WA |
34 ms |
22016 KB |
23.txt |
AC |
20 ms |
22144 KB |
24.txt |
AC |
31 ms |
21888 KB |
25.txt |
WA |
29 ms |
23040 KB |
26.txt |
WA |
33 ms |
22016 KB |
27.txt |
RE |
113 ms |
768 KB |
28.txt |
WA |
34 ms |
22016 KB |
29.txt |
AC |
18 ms |
22016 KB |
30.txt |
WA |
33 ms |
22016 KB |
31.txt |
WA |
28 ms |
23040 KB |
32.txt |
WA |
31 ms |
21888 KB |
33.txt |
WA |
29 ms |
23040 KB |
34.txt |
WA |
32 ms |
22016 KB |
35.txt |
TLE |
2103 ms |
23296 KB |
36.txt |
WA |
30 ms |
21760 KB |
37.txt |
AC |
15 ms |
21760 KB |
38.txt |
WA |
29 ms |
21760 KB |
39.txt |
AC |
15 ms |
21760 KB |
40.txt |
AC |
30 ms |
21760 KB |
41.txt |
WA |
26 ms |
22784 KB |
42.txt |
AC |
29 ms |
21760 KB |
43.txt |
WA |
26 ms |
22784 KB |
44.txt |
WA |
29 ms |
21760 KB |
45.txt |
WA |
26 ms |
22784 KB |
46.txt |
AC |
18 ms |
22016 KB |
47.txt |
WA |
32 ms |
22016 KB |
48.txt |
WA |
28 ms |
23040 KB |
49.txt |
WA |
31 ms |
22016 KB |
50.txt |
WA |
28 ms |
22912 KB |
51.txt |
WA |
31 ms |
21888 KB |
52.txt |
WA |
28 ms |
22912 KB |
53.txt |
WA |
31 ms |
21888 KB |
54.txt |
WA |
28 ms |
23040 KB |
55.txt |
WA |
31 ms |
22016 KB |
56.txt |
WA |
17 ms |
21888 KB |
57.txt |
AC |
32 ms |
22016 KB |
58.txt |
WA |
28 ms |
23040 KB |
59.txt |
WA |
30 ms |
21888 KB |
60.txt |
WA |
29 ms |
23040 KB |
61.txt |
WA |
31 ms |
22016 KB |
62.txt |
WA |
28 ms |
23040 KB |
63.txt |
WA |
31 ms |
22016 KB |
64.txt |
WA |
29 ms |
23040 KB |
65.txt |
WA |
31 ms |
22016 KB |
66.txt |
AC |
2 ms |
4352 KB |
67.txt |
AC |
2 ms |
4352 KB |