#include<bits/stdc++.h>
using namespace std;
const int N = 1e6;
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 |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
0 ms |
204 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 ms |
204 KB |
Ok |
11 |
Correct |
0 ms |
204 KB |
Ok |
12 |
Correct |
0 ms |
304 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
1 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
2 ms |
332 KB |
Ok |
7 |
Correct |
10 ms |
716 KB |
Ok |
8 |
Correct |
4 ms |
460 KB |
Ok |
9 |
Correct |
8 ms |
716 KB |
Ok |
10 |
Correct |
5 ms |
588 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
1 ms |
204 KB |
Ok |
4 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 7 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 5, pans = 3 |
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 |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
0 ms |
204 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 ms |
204 KB |
Ok |
11 |
Correct |
0 ms |
204 KB |
Ok |
12 |
Correct |
0 ms |
304 KB |
Ok |
13 |
Correct |
0 ms |
204 KB |
Ok |
14 |
Correct |
0 ms |
204 KB |
Ok |
15 |
Correct |
1 ms |
204 KB |
Ok |
16 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 7 |
17 |
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 |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
0 ms |
204 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 ms |
204 KB |
Ok |
11 |
Correct |
0 ms |
204 KB |
Ok |
12 |
Correct |
0 ms |
304 KB |
Ok |
13 |
Correct |
0 ms |
204 KB |
Ok |
14 |
Correct |
0 ms |
204 KB |
Ok |
15 |
Correct |
1 ms |
204 KB |
Ok |
16 |
Correct |
1 ms |
204 KB |
Ok |
17 |
Correct |
1 ms |
204 KB |
Ok |
18 |
Correct |
2 ms |
332 KB |
Ok |
19 |
Correct |
10 ms |
716 KB |
Ok |
20 |
Correct |
4 ms |
460 KB |
Ok |
21 |
Correct |
8 ms |
716 KB |
Ok |
22 |
Correct |
5 ms |
588 KB |
Ok |
23 |
Correct |
0 ms |
204 KB |
Ok |
24 |
Correct |
0 ms |
204 KB |
Ok |
25 |
Correct |
1 ms |
204 KB |
Ok |
26 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 7 |
27 |
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 |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
0 ms |
204 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 ms |
204 KB |
Ok |
11 |
Correct |
0 ms |
204 KB |
Ok |
12 |
Correct |
0 ms |
304 KB |
Ok |
13 |
Correct |
0 ms |
204 KB |
Ok |
14 |
Correct |
0 ms |
204 KB |
Ok |
15 |
Correct |
1 ms |
204 KB |
Ok |
16 |
Correct |
1 ms |
204 KB |
Ok |
17 |
Correct |
1 ms |
204 KB |
Ok |
18 |
Correct |
2 ms |
332 KB |
Ok |
19 |
Correct |
10 ms |
716 KB |
Ok |
20 |
Correct |
4 ms |
460 KB |
Ok |
21 |
Correct |
8 ms |
716 KB |
Ok |
22 |
Correct |
5 ms |
588 KB |
Ok |
23 |
Correct |
0 ms |
204 KB |
Ok |
24 |
Correct |
0 ms |
204 KB |
Ok |
25 |
Correct |
1 ms |
204 KB |
Ok |
26 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 7 |
27 |
Halted |
0 ms |
0 KB |
- |