#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n1, n, m;
bool tr;
vector <ll> a, p;
void f(int x){
if(tr == 1) return;
if(x == n1+1){
for(int i = 1; i <= n1; i++){
p[i] = p[i-1] + a[i];
}
bool tr1 = 0;
for(int i = 1; i <= n1; i++){
if(i >= m){
if(p[i] <= p[i-m]){
tr1 = 1;
break;
}
}
if(i >= n){
if(p[i] >= p[i-n]){
tr1 = 1;
break;
}
}
}
if(tr1 == 0){
tr = 1;
cout << n1 << '\n';
for(int i = 1; i <= n1; i++){
cout << a[i] << ' ';
}
cout << '\n';
}
return;
}
a[x] = (n < m ? (n + m) : -(n + m));
f(x+1);
a[x] = (n < m ? -(n + m + 1) : (n + m + 1));
f(x+1);
}
int main(){
int t;
cin >> t;
while(t--){
cin >> n >> m;
a.resize((n+m)*2+1);
p.assign((n+m)*2+1,0);
for(int i = (20); i >= 1; i--){
tr = 0;
n1 = i;
f(1);
if(tr) break;
}
if(tr == 0){
cout << 0 << "\n";
}
// cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
92 ms |
428 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
92 ms |
588 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
92 ms |
508 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
95 ms |
424 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
92 ms |
428 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
92 ms |
428 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
92 ms |
428 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |