#include <bits/stdc++.h>
using namespace std;
const int F = 1e6;
int T, N, M;
vector <int> v;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while (T--){
cin >> N >> M;
if (N == M){
cout << N-1 << '\n';
for (int i = 1; i < N; i++) cout << 1 << ' ';
cout << '\n';
continue;
}
if (N == 1){
cout << M-1 << '\n';
for (int i = 1; i < M; i++) cout << -1 << ' ';
cout << '\n';
continue;
}
if (M == 1){
cout << N-1 << '\n';
for (int i = 1; i < N; i++) cout << 1 << ' ';
cout << '\n';
continue;
}
bool rev = 0;
if (N > M){
rev = 1;
swap(N, M);
}
while (M%N != 1) M--;
cout << M+N-2 << '\n';
int d = M/N+1;
v.clear();
for (int i = 1; i <= M+N-2; i++)
if (i%N == 0) v.push_back(-N*d-1);
else v.push_back(d);
if (rev){
for (int &x : v) x = -x;
}
for (int x : v) cout << x << ' ';
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
2 |
Correct |
1 ms |
348 KB |
Ok |
3 |
Correct |
1 ms |
604 KB |
Ok |
4 |
Correct |
1 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
456 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
1 ms |
348 KB |
Ok |
9 |
Correct |
1 ms |
348 KB |
Ok |
10 |
Correct |
0 ms |
348 KB |
Ok |
11 |
Correct |
1 ms |
348 KB |
Ok |
12 |
Correct |
1 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
2 |
Correct |
1 ms |
348 KB |
Ok |
3 |
Correct |
1 ms |
604 KB |
Ok |
4 |
Correct |
1 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
456 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
1 ms |
348 KB |
Ok |
9 |
Correct |
1 ms |
348 KB |
Ok |
10 |
Correct |
0 ms |
348 KB |
Ok |
11 |
Correct |
1 ms |
348 KB |
Ok |
12 |
Correct |
1 ms |
348 KB |
Ok |
13 |
Incorrect |
1 ms |
348 KB |
there is incorrect sequence |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
2 |
Correct |
1 ms |
348 KB |
Ok |
3 |
Correct |
1 ms |
604 KB |
Ok |
4 |
Correct |
1 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
456 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
1 ms |
348 KB |
Ok |
9 |
Correct |
1 ms |
348 KB |
Ok |
10 |
Correct |
0 ms |
348 KB |
Ok |
11 |
Correct |
1 ms |
348 KB |
Ok |
12 |
Correct |
1 ms |
348 KB |
Ok |
13 |
Incorrect |
1 ms |
348 KB |
there is incorrect sequence |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Ok |
2 |
Correct |
1 ms |
348 KB |
Ok |
3 |
Correct |
1 ms |
604 KB |
Ok |
4 |
Correct |
1 ms |
348 KB |
Ok |
5 |
Correct |
1 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
456 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
1 ms |
348 KB |
Ok |
9 |
Correct |
1 ms |
348 KB |
Ok |
10 |
Correct |
0 ms |
348 KB |
Ok |
11 |
Correct |
1 ms |
348 KB |
Ok |
12 |
Correct |
1 ms |
348 KB |
Ok |
13 |
Incorrect |
1 ms |
348 KB |
there is incorrect sequence |
14 |
Halted |
0 ms |
0 KB |
- |