#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 1000000000;
#define int long long
#define F first
#define S second
#define pb push_back
#define ppb pop_back
int t, n, m, sum1, sum2 ;
vector<int> ans, v;
//void rec(){
//// if(n % m == 0 && ans.size() == n - 1){
//// return;
//// }
//// if(m % n == 0 && ans.size() == m - 1){
//// return;
//// }
//// cout << ans.size() << '\n';
// if(v.size() >= n){
// if(sum1 >= 0) return;
// }
// if(v.size() >= m){
// if(sum2 <= 0) return;
// }
// if(v.size() > ans.size()){
// ans = v;
// }
// if(v.size() >= n) sum1 -= v[v.size() - n];
// if(v.size() >= m) sum2 -= v[v.size() - m];
// for(int i = -10; i <= 10; ++i){
// sum1 += i;
// sum2 += i;
// v.pb(i);
// rec();
// v.ppb();
// sum1 -= i;
// sum2 -= i;
// }
// if(v.size() >= n) sum1 += v[v.size() - n];
// if(v.size() >= m) sum2 += v[v.size() - m];
//}
//1
//6 2
//5
//-9 10 -9 10 -9
//1
//6 3
//5
//-10 1 10 -10 1
//1
//6 4
//7
//-7 -10 8 10 -7 -10 8
//1
//6 5
//9
//-3 -2 -2 -2 10 -3 -2 -2 -2
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while(t--){
cin >> n >> m;
if(min(n, m) == 2 && n != m && max(n, m) % 2 == 0){
cout << max(n, m) << '\n';
if(n > m){
for(int i = 1; i <= n; ++i){
if(i % 2) cout << -(N - 1) << ' ';
else cout << N << ' ';
}
}
else{
for(int i = 1; i <= m; ++i){
if(i % 2) cout << N - 1 << ' ';
else cout << -N << ' ';
}
}
cout << '\n';
continue;
}
if(n > m){
cout << n - 1 << '\n';
for(int i = 1; i < n; ++i){
cout << 1 << ' ';
}
}
else{
cout << m - 1 << '\n';
for(int i = 1; i < m; ++i){
cout << -1 << ' ';
}
}
cout << '\n';
}
return 0;
}
Compilation message
sequence.cpp:69:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
69 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
1 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
0 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Jury has the better answer : jans = 3, pans = 2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 3, pans = 2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 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 |
204 KB |
Ok |
2 |
Correct |
1 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
0 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
1 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
0 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
1 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
0 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
11 |
Halted |
0 ms |
0 KB |
- |