QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#858333 | #9915. General Symmetry | Itgsurf# | TL | 12ms | 16220kb | C++14 | 743b | 2025-01-16 16:20:04 | 2025-01-16 16:20:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int mod=998244353;
const int N=4e5+5;
int n,m,k[10],l,mid[10];
int a[N],f[N][10];
int main(){
scanf("%d%d",&n,&k[0]),m=n*2+1;
while(k[l]) ++l,k[l]=k[l-1]/3;
for(int i=2;i<=m;i+=2)
scanf("%d",&a[i]);
for(int i=1;i<=m;++i){
for(int j=l;j>=0;--j){
int t=min(j+1,l);
if(mid[t]+f[mid[t]][t]>i) f[i][j]=min(mid[t]+f[mid[t]][t]-i,f[mid[t]*2-i][t]);
while(i-f[i][j]>1&&i+f[i][j]<m&&abs(a[i+f[i][j]+1]-a[i-f[i][j]-1])<=k[j]) ++f[i][j];
if(i+f[i]>mid[j]+f[mid[j]]) mid[j]=i;
}
}
for(int i=2;i<=m;i+=2) printf("%d ",f[i][0]);
puts("");
for(int i=3;i<m;i+=2) printf("%d ",f[i][0]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5964kb
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: 5964kb
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: 1ms
memory: 5960kb
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: 5796kb
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: 1ms
memory: 5968kb
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: 5964kb
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: 12ms
memory: 16220kb
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: 11ms
memory: 14232kb
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...