QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#792051 | #4063. 倍增 | propane | 80 | 975ms | 4284kb | C++20 | 3.6kb | 2024-11-28 23:07:06 | 2024-11-28 23:07:07 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
using LL = long long;
const int maxn = 2e5 + 5;
vector<int> f[maxn];
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n, B;
cin >> n >> B;
for(int len = 2; ; len++){
if (!f[B].empty()) break;
vector<int> p(len);
iota(p.begin(), p.end(), 0);
do{
for(int s = 1; s < 1 << (len - 1); s++){
vector<int> a(len);
vector<bool> v(len);
vector<int> c(len);
for(int i = 0; i < len - 1; i++){
c[i] = (s >> i & 1);
}
bool ok = true;
for(int i = 0; i < len; i++){
if (v[i]) continue;
vector<int> cycle;
for(int j = i; !v[j]; j = p[j]){
cycle.push_back(j);
v[j] = true;
}
const int m = cycle.size();
int k = 1, b = 0;
// a(p(j)) = a(j) * 2 - B * c(j) + c(j - 1)
for(int i = 1; i < m; i++){
k *= 2;
b = b * 2 - B * c[cycle[i - 1]] + (cycle[i - 1] >= 1 ? c[cycle[i - 1] - 1] : 0);
}
k *= 2;
b = b * 2 - B * c[cycle.back()] + (cycle.back() >= 1 ? c[cycle.back() - 1] : 0);
if (b % (k - 1)){
ok = false;
break;
}
a[cycle[0]] = -b / (k - 1);
k = 1, b = 0;
for(int i = 1; i < m; i++){
k *= 2;
b = b * 2 - B * c[cycle[i - 1]] + (cycle[i - 1] >= 1 ? c[cycle[i - 1] - 1] : 0);
a[cycle[i]] = k * a[cycle[0]] + b;
}
}
for(int i = 0; i < len; i++){
if (a[i] < 0 or a[i] >= B){
ok = false;
break;
}
}
if (ok){
reverse(a.begin(), a.end());
f[B] = a;
break;
}
}
}while(next_permutation(p.begin(), p.end()));
}
auto ans = f[B];
if (ans.size() > n){
cout << -1 << '\n';
continue;
}
for(int i = ans.size() - 1; i >= 0; i--){
if (ans[i] * 2 >= B){
vector<int> bk;
int cnt = ans.size() - i;
int need = n - ans.size();
while(cnt--){
bk.push_back(ans.back());
ans.pop_back();
}
while(need--){
ans.push_back(B - 1);
}
while(!bk.empty()){
ans.push_back(bk.back());
bk.pop_back();
}
break;
}
}
for(int i = 0; i < n; i++){
cout << ans[i] << " \n"[i + 1 == n];
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 4
Accepted
time: 1ms
memory: 3860kb
input:
10 4 4 8 3 8 3 1 4 2 2 6 5 2 3 8 8 3 2 7 2
output:
1 0 3 2 1 0 1 2 2 2 2 2 1 0 1 2 2 2 2 2 -1 0 1 1 4 4 4 4 3 -1 2 7 7 7 7 7 7 5 0 1 1 0 1 1 1 1 1 1
result:
ok Accepted
Test #2:
score: 4
Accepted
time: 4ms
memory: 3564kb
input:
10000 6 2 6 4 6 2 6 3 3 3 1 4 2 3 2 2 5 4 5 4 6 2 5 3 7 2 3 3 3 6 3 2 7 3 5 3 4 2 8 3 4 2 3 3 2 3 2 2 4 2 7 3 8 2 6 2 3 2 8 3 5 2 5 4 8 2 8 3 2 3 8 2 1 2 2 2 1 2 2 3 3 3 7 3 3 4 1 2 5 3 3 2 2 2 6 3 1 2 6 4 3 5 7 3 7 2 5 2 6 5 7 3 4 2 8 3 4 2 7 2 5 2 2 2 8 3 7 3 1 2 6 3 8 2 6 2 7 3 4 3 8 2 7 2 6 2 1 ...
output:
0 1 1 1 1 1 1 0 3 3 3 2 0 1 1 1 1 1 1 0 1 2 2 2 -1 -1 -1 0 1 1 0 3 3 2 1 0 3 3 2 0 1 1 1 1 1 1 0 1 2 2 0 1 1 1 1 1 1 -1 -1 0 1 1 1 0 1 2 2 2 2 1 0 1 2 2 0 1 1 1 1 0 1 2 2 2 2 2 0 1 1 1 -1 -1 0 1 0 1 1 1 1 0 1 2 2 2 2 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 2 2 2 2 2 0 1 1 1 1 1 0 3 3 2 0 1 1 1 1 1 1...
result:
ok Accepted
Test #3:
score: 4
Accepted
time: 4ms
memory: 4284kb
input:
10 2 3 4 2 2 4 192276 5 11 3 6 7 7492 2 8 2 197 8 2 3
output:
-1 0 1 1 1 -1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
ok Accepted
Test #4:
score: 4
Accepted
time: 9ms
memory: 3644kb
input:
10000 7 2 84 2 8 3 1 2 7 2 2 3 10 2 4 3 6 2 8 3 1 2 2 2 37 2 380 2 7 2 3 2 7 2 8 2 8 3 6 2 5 2 6 3 5 2 29 2 2 3 2 2 5 2 7 3 4 2 3 2 4 2 1 2 6 2 8 2 5 4 1 2 5 4 8 2 1 2 6 2 8 3 6 2 6 3 4 2 32 2 6 3 1 2 3 2 7 4 4 2 3 5 7 2 434 4 5 2 1 2 8 2 24 2 5 2 5 2 6 2 4 2 1 6 2 3 7 2 5 4 10 2 10 5 8 2 4 3 8 2 3 ...
output:
0 1 1 1 1 1 1 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 0 1 2 2 2 2 2 -1 0 1 1 1 1 1 1 -1 0 1 1 1 1 1 1 1 1 1 1 0 1 2 0 1 1 1 1 1 1 0 1 2 2 2 2 2 -1 0 1 0 1 1 1 1 1 1 1 1 1...
result:
ok Accepted
Test #5:
score: 4
Accepted
time: 9ms
memory: 3648kb
input:
10000 3 3 1 2 48 2 3 2 7 3 2 2 61 2 6 3 6 2 7 3 3 3 3 2 4 2 4 2 6 2 1 3 6 2 4 2 127 2 51 3 5 6 6 2 51 6 7 2 6 2 4 3 7 2 2 6 3 2 3 2 3 2 8 2 6 3 7 4 3 4 4 2 8 2 5 3 8 3 6 2 6 2 2 4 5 2 4 2 3 3 5 3 2 2 8 2 2 3 5 3 12 2 7 3 5 2 6 4 4 3 2 2 3 3 4 2 5 3 3 3 5 2 8 2 5 2 2 2 7 2 5 2 7 2 8 2 2 2 1 3 7 2 5 2...
output:
-1 -1 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 0 1 1 1 0 1 2 2 2 2 0 1 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 0 1 2 2 2 0 1 1 1 1 1 1 0 1 2 2 2 2 -1 0 1 1 0 1 1...
result:
ok Accepted
Test #6:
score: 4
Accepted
time: 4ms
memory: 3848kb
input:
100 1 10 2 11 8 3 8 3 2 3 8 3 1 5 5 7 2 4 6 5 7 10 10 7 8 3 8 10 7 4 6 5 10 4 2 5 4 2 5 3 2 3 4 6 7 3 6 8 8 10 6 7 5 5 2 2 4 12 7 2 2 8 5 15 4 13 6 5 6 10 2 12 1 4 3 5 8 9 1 3 8 8 4 3 5 5 4 13 7 2 5 4 3 5 8 2 2 7 1 4 2 5 6 3 1 5 8 11 9 10 3 12 2 6 4 5 5 4 3 2 7 5 8 4 2 9 4 3 6 9 1 5 7 8 4 2 10 4 15 ...
output:
-1 3 7 1 0 1 2 2 2 2 2 1 0 1 2 2 2 2 2 -1 1 0 1 2 2 2 2 2 -1 1 2 5 6 4 -1 1 4 4 4 4 3 2 8 5 9 7 4 1 1 2 5 6 6 6 6 6 6 4 1 0 1 2 2 2 2 2 2 8 5 9 9 7 4 1 1 0 3 3 3 3 2 1 4 4 4 4 3 1 0 3 3 3 3 3 3 3 2 1 3 0 1 1 1 1 0 1 2 2 -1 2 1 3 4 1 0 1 2 2 2 2 2 7 7 7 7 5 2 8 5 9 9 7 4 1 1 2 5 6 6 4 1 4 4 4 3 0 1 4...
result:
ok Accepted
Test #7:
score: 4
Accepted
time: 11ms
memory: 3552kb
input:
100 4 10 3 18 4 31 7 10 3 4 4 13 1 14 3 33 6 8 3 34 2 16 5 8 9 26 5 18 7 16 15 12 8 16 3 10 8 18 40 6 4 2 1 12 1 28 5 17 8 20 4 2 7 30 1 16 2 30 6 31 4 32 8 21 8 28 2 12 8 3 15 23 8 11 37 3 4 12 2 13 2 17 2 15 3 34 16 24 3 10 4 17 1 5 2 17 7 12 7 12 4 17 7 15 8 15 5 24 2 40 3 6 6 2 27 4 8 32 1 36 1 ...
output:
-1 5 2 10 -1 2 8 5 9 7 4 1 1 0 2 5 2 7 10 -1 -1 2 7 7 7 7 5 -1 -1 2 7 7 7 5 8 25 25 25 25 25 25 25 17 5 2 17 17 10 2 4 15 15 15 15 9 4 3 7 11 11 11 11 11 11 11 11 11 11 11 8 2 4 15 15 15 15 15 9 -1 5 2 17 17 17 17 17 10 2 1 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 ...
result:
ok Accepted
Test #8:
score: 4
Accepted
time: 20ms
memory: 3620kb
input:
100 2 93 6 69 14 82 49 80 1 50 9 64 7 31 5 31 2 13 6 100 4 93 4 19 6 18 2 37 2 76 1 60 8 33 5 68 3 6 2 93 57 41 2 79 6 78 47 34 9 61 7 66 3 13 3 12 5 15 7 57 8 66 6 45 5 59 4 23 1 98 6 90 1 8 30 33 8 49 2 82 38 86 6 49 29 12 6 10 7 90 7 63 5 2 8 57 4 64 5 72 8 76 6 15 4 78 28 63 60 30 37 87 6 14 7 4...
output:
-1 23 22 45 68 68 46 16 32 65 81 81 81 81 81 81 81 81 81 81 49 26 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 53 -1 4 17 8 63 63 63 63 63 34 6 17 13 27 30 24 3 -1 -1 14 28 99 99 99 57 13 26 92 53 1 5 2 1...
result:
ok Accepted
Test #9:
score: 4
Accepted
time: 25ms
memory: 3568kb
input:
100 4 150 3 25 1 213 36 202 4 96 4 211 8 176 50 182 5 221 93 63 4 108 1 100 1 8 30 6 27 131 2 80 5 157 6 192 300 65 7 12 20 192 88 103 7 236 50 97 6 256 7 136 8 187 8 40 2 17 1 71 2 243 7 200 70 123 7 91 14 266 4 77 3 127 3 61 4 94 3 161 2 45 6 165 3 261 7 160 7 115 1 138 148 50 8 105 8 256 1 67 88 ...
output:
50 49 99 100 7 3 14 -1 40 80 161 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 121 32 31 63 64 -1 58 175 175 175 175 175 175 117 60 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 18...
result:
ok Accepted
Test #10:
score: 4
Accepted
time: 117ms
memory: 3860kb
input:
100 11 840 2 9 5 501 3 691 5 287 29 599 7 407 88 97 5 775 5 307 3 499 1 610 8 432 8 820 64 85 7 39 6 691 6 544 2 387 4 626 6 611 7 158 8 236 69 502 7 432 6 160 2 516 8 866 8 242 3 558 6 433 6 177 6 88 679 460 4 253 7 505 4 565 9 931 8 366 6 331 7 640 4 778 60 4 4 667 1 913 5 376 29 88 3 59 8 441 3 7...
output:
280 279 559 839 839 839 839 839 839 839 560 -1 143 71 500 500 286 -1 95 286 286 286 191 199 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 598 399 135 406 406 406 406 406 271 19 38 77 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96...
result:
ok Accepted
Test #11:
score: 4
Accepted
time: 975ms
memory: 3736kb
input:
100 7 1391 7 2313 8 1127 3 674 1 845 5 2167 25 2265 70 92 8 2611 453 586 7 667 8 2280 7 1891 1 2897 60 26 4 2325 7 945 3000 608 7 1351 23 25 71 1435 5 2518 7 2669 6 91 6 243 5 2596 7 2114 4 1864 19 283 5 2958 31 50 7 1642 2052 17 6 505 108 2099 7 1379 17 1078 1400 1516 7 902 5 2629 7 1981 6 91 9 565...
output:
463 1390 1390 1390 1390 1390 927 771 770 1541 2312 2312 2312 1542 375 1126 1126 1126 1126 1126 1126 751 224 673 449 -1 619 309 2166 2166 1238 647 323 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 2264 1294 30 91 91 91 91 91 91 91 91 91 91 91...
result:
ok Accepted
Test #12:
score: 4
Accepted
time: 874ms
memory: 3716kb
input:
100 8 9451 1 1885 3 433 6 763 2 53 3 1590 6 8566 4 1807 2 1514 7 10720 4 2103 622 155 98 22 4 1096 2 878 2129 562 2 582 5 37 4 2043 8 353 183 1550 6 2129 1 664 2 368 4598 514 51 2 8 8191 9 8335 51 99 5 974 1444 1405 6 513 5 777 3121 1395 8 139 6 1585 7 2113 8 10891 58 79 1 1748 5 114 4 675 4 1299 68...
output:
3051 3125 5506 6102 2753 1562 9450 6251 -1 -1 305 152 457 762 762 610 17 35 -1 951 6662 3807 1903 4758 7614 361 722 1445 1084 504 1009 3062 9188 6125 10719 7657 4594 1531 701 700 1401 1402 51 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 ...
result:
ok Accepted
Test #13:
score: 0
Time Limit Exceeded
input:
100 4 5 43 6 19 5 5 2 76 92 36 31 1 2 7 8 73 37 7 6541 9 196 5 3190 6 47755 3 4 8 5 8 7066 31 13 3 6 53 17 50000 6 6 6 10400 5 4591 2 3 3 6 2 6 11 2 2 6 2 1 4 36 74 7219 4 6 5 4 6 6 4 62 6 7 9 5 5 8 2 2 4 98 83 5 4 61 40 5 4 3 3 215 10 5 4 33830 10 12 2 8 11 8 9 10 12 1 6 6 2 6 3580 3 2 1943 6 8 283...
output:
1 4 4 3 2 1 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 0 1 1 1 1 30 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91...
result:
Test #14:
score: 0
Time Limit Exceeded
input:
100 47 11 30210 3 7 2 8 72136 1 2 56 50 7 3 8 1270 4 4 5 4 72 90 1 9 7 7 5 7 7 5 29 3 6 7 5931 3 12 7 8 3 6 6 7 7 2 4 8 2 435 6 182 3 7 48385 7 5 80 3 8 4 1 3 9 160 7 346 8 17326 8952 4 2 3 1799 3 6 3 8 61 7 4 70 99 6 2 6 5 1091 2 8 3 3 5 1 9 8 3 8 7 2 2 4 4 14 94 13586 5 58 90 4 2 7 4 6 1216 8 3 38...
output:
3 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 7 1 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
result:
Test #15:
score: 4
Accepted
time: 38ms
memory: 3640kb
input:
1500 101 13 103 130 109 39 102 108 104 52 105 165 100 28 105 103 100 42 108 37 100 144 105 160 105 13 105 113 111 25 107 61 101 126 103 97 111 20 105 146 140 14 107 35 103 123 103 12 105 142 108 92 100 64 106 74 107 78 106 165 108 13 108 42 102 19 104 66 101 33 103 22 100 17 100 84 101 104 104 98 10...
output:
5 2 7 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 10 ...
result:
ok Accepted
Test #16:
score: 4
Accepted
time: 899ms
memory: 3928kb
input:
1300 108 88 103 212 105 174 542 39 108 110 218 262 106 28 103 166 103 47 102 11 101 41 108 193 101 288 107 131 101 6 101 206 103 125 1434 115 104 118 146 29 105 165 107 28 106 32 102 79 102 186 107 225 106 36 105 39 102 56 210 20 102 7 101 26 105 159 104 93 108 260 107 204 101 168 103 38 103 137 151...
output:
25 12 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 ...
result:
ok Accepted
Test #17:
score: 0
Time Limit Exceeded
input:
1000 106 3 101 391 102 2 101 3 108 2 106 3 100 2 108 2 102 3 107 3 845 2 108 2 103 2 106 2 231 2 103 4 102 2 105 2 108 2 103 2 106 2 131 2 102 2 108 2 107 2 100 2 100 2 108 2 104 2 108 2 112 2 100 2 100 2 242 4 1895 2 104 2 106 2 105 2 100 3 986 3 136 2 103 2 112 2 104 3 102 3 103 2 104 2 100 2 107 ...
output:
1 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 86 217 173 347 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 3...
result:
Test #18:
score: 4
Accepted
time: 3ms
memory: 3872kb
input:
10000 4 5 7 2 4 83 3 68 2 8 1 47 15 5 2 2 5 2 2 2 6 68 1 5 6 56 3 2 2 17 1 80 6 5 7 17 8 8 6 41 8 89 9 14 7 32 5 17 2 2 76 23 8 2 7 20 6 5 2 38 3 5 8 53 3 5 1 86 2 23 4 2 3 2 6 2 2 44 2 53 245 77 4 32 4 8 2 2 6 5 7 2 1 2 7 8 1 2 5 2 1 29 1 2 7 2 6 62 3 20 3 35 130 2 5 8 7 14 6 17 4 2 6 14 3 2 6 14 8...
output:
1 4 4 3 0 1 1 1 1 1 1 27 82 82 55 22 67 45 2 5 -1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 3 0 1 0 1 1 1 1 0 1 22 67 67 67 67 45 -1 18 55 55 55 55 37 0 1 1 5 11 -1 1 4 4 4 4 3 5 16 16 16 16 16 11 2 7 7 7 7 7 7 5 13 40 40 40 40 27 29 88 88 88 88 88 88 59 4 13 13 13 13 13 13 13 9 10 31 31 31 31 31 21 5 16 16 16 11...
result:
ok Accepted
Test #19:
score: 4
Accepted
time: 9ms
memory: 3572kb
input:
10000 4 2 6 2 7 35 8 53 7 14 1 20 8 2 2 2 47 59 8 5 4 77 6 2 5 26 3 26 1 2 4 2 7 41 8 74 3 2 3 2 5 5 5 14 7 32 3 5 3 2 6 2 4 32 5 44 4 14 8 32 6 8 6 2 7 2 15 2 1 8 3 2 7 2 2 11 8 44 1 5 1 56 4 23 1 14 4 5 1 5 1 2 1 8 8 50 90 2 1 8 2 2 154 2 6 2 4 2 1 44 4 56 177 2 6 17 1 2 7 5 1 11 8 56 7 2 6 2 6 17...
output:
0 1 1 1 0 1 1 1 1 1 11 34 34 34 34 34 23 17 52 52 52 52 52 52 35 4 13 13 13 13 13 9 -1 0 1 1 1 1 1 1 1 0 1 19 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 39 1 4 4 4 4 4 4 3 25 76 76 51 0 1 1 1 1 1 8 25 25 25 1...
result:
ok Accepted
Test #20:
score: 4
Accepted
time: 7ms
memory: 3876kb
input:
10000 1 12 144 3 6 3 5 48 1 18 2 21 6 45 3 42 5 18 8 3 7 3 8 6 7 39 2 3 7 15 2 3 2 6 1 3 49 27 2 54 6 39 8 3 8 30 1 3 4 3 8 3 6 54 7 12 3 39 8 42 6 12 8 9 7 12 15 6 6 24 6 3 3 27 5 3 7 3 5 27 3 3 4 15 5 45 7 36 3 9 8 6 1 51 162 12 4 18 7 3 4 72 1 21 6 3 120 3 10 15 1 21 3 3 5 63 2 9 2 9 3 33 8 63 3 ...
output:
-1 1 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 1 2 2...
result:
ok Accepted
Test #21:
score: 4
Accepted
time: 5ms
memory: 3872kb
input:
10000 1 54 4 3 265 18 406 3 2 66 2 21 3 51 6 69 18 6 3 3 137 3 6 54 1 3 2 15 2 30 6 18 4 63 1 9 396 6 3 6 1 30 155 3 9 66 3 57 4 39 1 54 7 30 3 21 1 15 7 15 2 3 3 27 2 3 92 12 2 21 3 3 4 15 3 45 7 27 44 6 8 3 8 12 3 15 8 15 5 3 7 30 1 3 2 12 8 3 4 12 2 96 8 33 5 3 5 3 4 9 9 3 2 54 4 3 5 6 1 3 110 3 ...
output:
-1 1 0 1 2 5 2 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 ...
result:
ok Accepted
Test #22:
score: 4
Accepted
time: 22ms
memory: 3576kb
input:
10000 6 18 4 37 4 40 1 16 6 6 8 14 7 7 4 12 5 32 7 29 2 13 4 39 1 10 1 27 6 31 3 11 6 14 8 32 6 16 6 13 7 10 4 8 1 42 24 18 6 7 1 37 7 4 6 8 7 13 6 26 8 34 3 38 3 21 4 7 60 15 2 29 6 29 8 27 4 36 7 32 5 31 1 22 3 7 3 12 8 32 3 13 3 5 7 30 5 37 3 27 6 18 2 29 6 23 8 24 5 17 36 12 4 24 8 19 2 11 6 22 ...
output:
5 2 17 17 17 10 5 10 36 21 -1 -1 2 1 3 5 5 4 4 13 13 13 13 13 13 9 1 2 5 6 6 6 4 4 3 7 8 10 31 31 31 21 9 28 28 28 28 28 19 -1 11 5 38 22 -1 -1 6 17 13 27 24 3 3 10 7 4 13 13 13 13 9 10 31 31 31 31 31 31 21 2 4 15 15 15 9 5 2 7 12 12 10 2 8 5 9 7 4 1 2 7 7 5 -1 5 2 17 17 17 17 17 17 17 17 17 17 17 1...
result:
ok Accepted
Test #23:
score: 4
Accepted
time: 856ms
memory: 3604kb
input:
10000 8 4 5 4 1 3 7 23 6 32 1 25 8 23 1 7 5 29 6 23 8 18 1 28 8 30 3 20 6 39 8 36 1 16 393 3 5 3 3 28 8 19 6 5 6 7 8 5 5 6 2 35 1 24 5 19 7 4 1 9 4 13 3 22 4 16 6 21 1 15 7 9 8 29 8 10 17 14 2 27 8 13 2 18 5 17 8 23 44 32 7 11 18 13 3 7 1 20 6 37 3 2 2 3 3 2 304 17 132 5 14 20 5 10 2 40 5 2 2 18 6 7...
output:
1 0 3 3 3 3 3 2 1 0 3 3 2 -1 7 22 22 22 22 22 15 10 31 31 31 31 21 -1 7 22 22 22 22 22 22 15 -1 9 28 28 28 19 7 22 22 22 22 15 5 2 17 17 17 17 17 10 -1 4 8 29 29 29 29 29 17 6 19 13 11 5 38 38 38 22 12 11 23 35 35 35 35 24 -1 1 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok Accepted
Test #24:
score: 0
Time Limit Exceeded
input:
10000 4 2 12 2 5 2 5 2 234 2 6 2 7 2 14 2 368 2 6 2 8 2 8 2 8 2 8 2 7 2 2 2 2 2 8 2 5 2 3 2 6 2 7 2 7 2 7 2 4 2 5 2 55 2 8 2 3 2 3 2 2 2 8 2 11 2 2 2 8 2 8 2 31 2 8 2 8 2 192 2 4 2 8 2 2 2 2 2 4 2 7 2 2 2 3 3 7 2 5 2 1 2 2 2 2 2 1 2 8 2 5 2 17 2 7 2 4 2 151 2 4 2 6 2 8 2 5 2 8 2 2 2 68 2 6 2 1 2 6 2...
output:
0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 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 ...
result:
Test #25:
score: 0
Time Limit Exceeded
input:
10000 7 2 2 2 6 2 3 2 6 2 3 2 7 2 6 2 6 2 2 2 1 2 4 2 3 2 57 2 7 2 8 2 44 2 3 2 6 2 3 2 332 2 3 2 8 2 7 2 4 2 8 2 4 2 2 2 6 2 36 2 5 2 2 2 8 2 2 2 8 2 3 2 4 2 7 2 3 2 6 2 8 2 7 2 8 2 18 2 8 2 8 2 4 2 2 2 7 2 8 2 2 3 8 2 3 2 5 2 4 3 4 2 6 2 1 2 3 2 4 2 2 2 5 2 3 2 135 2 3 2 4 2 6 2 3 2 361 2 7 2 5 2 ...
output:
0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 -1 0 1 1 1 0 1 1 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 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...