#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);
f(x+1);
a[x] = 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 = (n+m)+2; 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 |
Execution timed out |
2072 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
336 KB |
Jury has the better answer : jans = 3, pans = 2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Ok |
2 |
Correct |
1 ms |
336 KB |
Ok |
3 |
Incorrect |
2 ms |
336 KB |
Jury has the better answer : jans = 3, pans = 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
336 KB |
Jury has the better answer : jans = 5, pans = 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2072 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2072 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2072 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |