#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define PB push_back
using namespace std;
const int N = 200100;
const int PW = 20;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int qq; cin >> qq;
for (; qq; qq--){
int n, m;
cin >> n >> m;
// assert((max(n, m) % min(n, m)) == 0);
if (n == m){
cout << n - 1 << '\n';
for (int i = 1; i < n; i++)
cout << "1 ";
cout << '\n';
continue;
}
if (max(n, m) % min(n, m) == 0){
if (n > m){
cout << n - 1 << '\n';
for (int i = 0; i < n - 1; i++)
if (i % m == 0)
cout << +int(1e8) << " " ;
else cout << "-1 ";
cout << '\n';
} else {
cout << m - 1 << '\n';
for (int i = 0; i < m - 1; i++)
if (i % n == 0)
cout << -int(1e8) << " " ;
else cout << "1 ";
cout << '\n';
}
continue;
}
if (min(n, m) == 2){
if (n > m){
cout << n << '\n';
for (int i = 0; i < n; i++)
if (i & 1)
cout << int(1e9) << " ";
else cout << -int(1e9) + 1 << " ";
cout << '\n';
} else {
cout << m << '\n';
for (int i = 0; i < m; i++)
if (i & 1)
cout << -int(1e9) << " ";
else cout << +int(1e9) - 1 << " ";
cout << '\n';
}
continue;
}
int m1 = 1, m2 = -1;
if (n > m){
swap(n, m);
m1 = -1; m2 = 1;
}
if (n == 3 && m == 4){
cout << "5\n";
cout << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << " " << m1 << '\n';
continue;
}
if (n == 3 && m == 5){
cout << "5\n";
cout << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << " " << m1 << '\n';
continue;
}
if (n == 3 && m == 7){
cout << "7\n";
cout << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << '\n';
continue;
}
if (n == 3 && m == 8){
cout << "8\n";
cout << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << " " << m1 << '\n';
continue;
}
if (n == 3 && m == 10){
cout << "10\n";
cout << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << " " << m1 << " " << m2 * 3 << " " << m1 << '\n';
continue;
}
return -1;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
2 ms |
256 KB |
Ok |
4 |
Correct |
2 ms |
376 KB |
Ok |
5 |
Correct |
2 ms |
348 KB |
Ok |
6 |
Correct |
2 ms |
376 KB |
Ok |
7 |
Correct |
2 ms |
252 KB |
Ok |
8 |
Correct |
2 ms |
376 KB |
Ok |
9 |
Correct |
2 ms |
276 KB |
Ok |
10 |
Correct |
2 ms |
376 KB |
Ok |
11 |
Correct |
2 ms |
376 KB |
Ok |
12 |
Correct |
2 ms |
376 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
2 ms |
376 KB |
Ok |
4 |
Correct |
2 ms |
376 KB |
Ok |
5 |
Correct |
2 ms |
376 KB |
Ok |
6 |
Correct |
4 ms |
504 KB |
Ok |
7 |
Correct |
9 ms |
1144 KB |
Ok |
8 |
Correct |
5 ms |
632 KB |
Ok |
9 |
Correct |
10 ms |
1144 KB |
Ok |
10 |
Correct |
7 ms |
888 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
2 ms |
376 KB |
Ok |
4 |
Incorrect |
2 ms |
376 KB |
Jury has the better answer : jans = 9, pans = 8 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
376 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
2 ms |
256 KB |
Ok |
4 |
Correct |
2 ms |
376 KB |
Ok |
5 |
Correct |
2 ms |
348 KB |
Ok |
6 |
Correct |
2 ms |
376 KB |
Ok |
7 |
Correct |
2 ms |
252 KB |
Ok |
8 |
Correct |
2 ms |
376 KB |
Ok |
9 |
Correct |
2 ms |
276 KB |
Ok |
10 |
Correct |
2 ms |
376 KB |
Ok |
11 |
Correct |
2 ms |
376 KB |
Ok |
12 |
Correct |
2 ms |
376 KB |
Ok |
13 |
Correct |
2 ms |
376 KB |
Ok |
14 |
Correct |
2 ms |
376 KB |
Ok |
15 |
Correct |
2 ms |
376 KB |
Ok |
16 |
Incorrect |
2 ms |
376 KB |
Jury has the better answer : jans = 9, pans = 8 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
2 ms |
256 KB |
Ok |
4 |
Correct |
2 ms |
376 KB |
Ok |
5 |
Correct |
2 ms |
348 KB |
Ok |
6 |
Correct |
2 ms |
376 KB |
Ok |
7 |
Correct |
2 ms |
252 KB |
Ok |
8 |
Correct |
2 ms |
376 KB |
Ok |
9 |
Correct |
2 ms |
276 KB |
Ok |
10 |
Correct |
2 ms |
376 KB |
Ok |
11 |
Correct |
2 ms |
376 KB |
Ok |
12 |
Correct |
2 ms |
376 KB |
Ok |
13 |
Correct |
2 ms |
376 KB |
Ok |
14 |
Correct |
2 ms |
376 KB |
Ok |
15 |
Correct |
2 ms |
376 KB |
Ok |
16 |
Correct |
2 ms |
376 KB |
Ok |
17 |
Correct |
2 ms |
376 KB |
Ok |
18 |
Correct |
4 ms |
504 KB |
Ok |
19 |
Correct |
9 ms |
1144 KB |
Ok |
20 |
Correct |
5 ms |
632 KB |
Ok |
21 |
Correct |
10 ms |
1144 KB |
Ok |
22 |
Correct |
7 ms |
888 KB |
Ok |
23 |
Correct |
2 ms |
376 KB |
Ok |
24 |
Correct |
2 ms |
376 KB |
Ok |
25 |
Correct |
2 ms |
376 KB |
Ok |
26 |
Incorrect |
2 ms |
376 KB |
Jury has the better answer : jans = 9, pans = 8 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Ok |
2 |
Correct |
2 ms |
376 KB |
Ok |
3 |
Correct |
2 ms |
256 KB |
Ok |
4 |
Correct |
2 ms |
376 KB |
Ok |
5 |
Correct |
2 ms |
348 KB |
Ok |
6 |
Correct |
2 ms |
376 KB |
Ok |
7 |
Correct |
2 ms |
252 KB |
Ok |
8 |
Correct |
2 ms |
376 KB |
Ok |
9 |
Correct |
2 ms |
276 KB |
Ok |
10 |
Correct |
2 ms |
376 KB |
Ok |
11 |
Correct |
2 ms |
376 KB |
Ok |
12 |
Correct |
2 ms |
376 KB |
Ok |
13 |
Correct |
2 ms |
376 KB |
Ok |
14 |
Correct |
2 ms |
376 KB |
Ok |
15 |
Correct |
2 ms |
376 KB |
Ok |
16 |
Correct |
2 ms |
376 KB |
Ok |
17 |
Correct |
2 ms |
376 KB |
Ok |
18 |
Correct |
4 ms |
504 KB |
Ok |
19 |
Correct |
9 ms |
1144 KB |
Ok |
20 |
Correct |
5 ms |
632 KB |
Ok |
21 |
Correct |
10 ms |
1144 KB |
Ok |
22 |
Correct |
7 ms |
888 KB |
Ok |
23 |
Correct |
2 ms |
376 KB |
Ok |
24 |
Correct |
2 ms |
376 KB |
Ok |
25 |
Correct |
2 ms |
376 KB |
Ok |
26 |
Incorrect |
2 ms |
376 KB |
Jury has the better answer : jans = 9, pans = 8 |
27 |
Halted |
0 ms |
0 KB |
- |