QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834231 | #9915. General Symmetry | MCPlayer542# | TL | 16ms | 11992kb | C++14 | 830b | 2024-12-27 14:05:28 | 2024-12-27 14:05:28 |
Judging History
answer
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int inf=-1e9;
int n,m,k[10],p[10],mx[10],kc=0,l,s[400010],a[400010][10];
inline int ab(int x)
{
return x<0?-x:x;
}
int main()
{
scanf("%d%d",&n,&k[0]);
while(k[kc])
{
k[kc+1]=k[kc]/3;
++kc;
}
for(int i=0;i<n*2+1;++i) s[i]=inf;
for(int i=0;i<n;++i) scanf("%d",&s[i<<1|1]);
n=n<<1|1;
for(int i=0;i<n;++i)
for(int j=kc,pr;~j;--j)
{
pr=min(j+1,kc);
a[i][j]=i<mx[pr]?min(a[p[pr]*2-i][pr],mx[pr]-i):1;
for(;i-a[i][j]>=0&&i+a[i][j]<n&&ab(s[i+a[i][j]]-s[i-a[i][j]])<=k[j];++a[i][j]) if(i+a[i][j]>mx[j])
{
mx[j]=i+a[i][j];
p[j]=i;
}
}
for(int i=1;i<n-1;++i) if(i&1) printf("%d ",a[i][0]-1);putchar('\n');
for(int i=1;i<n-1;++i) if(~i&1) printf("%d ",a[i][0]-1);putchar('\n');
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1652kb
input:
5 0 1 2 1 2 1
output:
1 3 5 3 1 0 0 0 0
result:
ok 9 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
5 1 1 2 1 3 1
output:
1 3 5 3 1 2 2 0 0
result:
ok 9 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
10 0 1 2 3 4 500 5 501 6 499 503
output:
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
result:
ok 19 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
10 1 1 2 3 4 500 5 501 6 499 503
output:
1 1 1 1 3 3 5 1 1 1 2 2 2 0 0 0 0 0 0
result:
ok 19 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 1604kb
input:
10 2 1 2 3 4 500 5 501 6 499 503
output:
1 3 3 1 3 5 5 3 1 1 2 2 2 0 0 0 0 0 0
result:
ok 19 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
10 10 1 2 3 4 500 5 501 6 499 503
output:
1 3 3 1 3 5 5 3 1 1 2 4 2 0 0 0 0 0 2
result:
ok 19 numbers
Test #7:
score: 0
Accepted
time: 16ms
memory: 11992kb
input:
100000 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...
result:
ok 199999 numbers
Test #8:
score: 0
Accepted
time: 13ms
memory: 11856kb
input:
100000 0 2 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 1 2 1 2 2 1 1 1 2 2 2 2 2 1 1 2 2 1 2 1 2 2 1 1 1 2 2 2 1 2 1 2 2 1 2 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 1 1 2 1 2 2 1 2 1 1 2 2 1 1 1 2 1 2 1 2 2 2 1 2 1 1 1 2 1 2 1 2 1 1 2 1 1 2 2 1 1 2 2 1 1 2 1 2 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2...
output:
1 3 3 1 3 11 3 1 3 17 3 1 3 9 3 1 5 1 1 3 5 5 3 1 1 1 7 1 1 3 9 3 1 1 1 1 1 3 11 3 1 1 1 7 1 1 5 1 3 7 3 1 1 3 5 5 3 1 1 1 5 1 13 1 5 1 1 1 1 3 3 1 1 3 3 1 3 3 1 1 3 3 1 1 1 1 1 5 1 3 5 5 3 1 9 1 3 3 1 9 1 3 5 9 5 3 1 1 7 1 1 1 1 1 1 1 1 1 1 3 7 3 1 3 3 1 1 3 3 1 1 3 5 9 5 3 1 3 13 3 1 3 9 3 1 5 1 1...
result:
ok 199999 numbers
Test #9:
score: -100
Time Limit Exceeded
input:
100000 1 2 2 1 2 1 2 1 1 2 1 1 2 1 2 2 2 1 1 1 1 2 2 2 1 1 2 1 2 2 2 2 2 1 1 2 2 2 1 2 2 2 2 2 1 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 1 1 1 2 1 1 1 2 1 2 2 1 2 2 2 2 1 2 2 1 2 2 2 1 1 1 2 1 1 1 2 1 2 2 1 2 2 1 1 1 1 2 2 2 1 1 2 2 2 1 2 1 2 2 2 1 1 1 1 2 2 1 1 1 1 2 1 2 2 2 2 1 1 1 2 1 2 1 1 2 2 1 1 2 2 1 2...