#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=200006, INF=1e18;
ll pos, l, r, n, m, t, a[N], b[N], h[N], p[20][N], q, k, x, y;
vector <ll> v[N];
set <ll> s[N], S[N];
int main(){ios_base::sync_with_stdio(false), cin.tie(0);
cin>>q;
while(q--){
cin>>n>>m;
if (n>m){
if(n%m==0){
cout<<n-1<<'\n';
for (int i=1; i<n; i++)cout<<"1 ";
cout<<'\n';
continue;
}
if(m==2){
cout<<n<<"\n-999999999 ";
for (int i=1; i<n; i+=2)cout<<"1000000000 -999999999 ";
cout<<'\n';
continue;
}
if(n==m+2&&n%2==1){
cout<<2*m<<'\n';
for (int i=1; i<m; i+=2)cout<<m<<" "<<-n<<" ";
cout<<m<<" "<<m<<" ";
for (int i=1; i<m; i+=2)cout<<-n<<" "<<m<<" ";
cout<<'\n';
continue;
}
if(n==m+1||n==m+2){
cout<<m*2-1<<'\n';
for (int i=1; i<m; i++)cout<<"-2 ";
cout<<2*m-1;
for (int i=1; i<m; i++)cout<<" -2";
cout<<'\n';
continue;
}
}else{
if(m%n==0){
cout<<m-1<<'\n';
for (int i=1; i<m; i++)cout<<"-1 ";
cout<<'\n';
continue;
}
if(n==2){
cout<<m<<"\n999999999 ";
for (int i=1; i<m; i+=2)cout<<"-1000000000 999999999 ";
cout<<'\n';
continue;
}
if(m==n+2&&m%2==1){
cout<<2*n<<'\n';
for (int i=1; i<n; i+=2)cout<<-n<<" "<<m<<" ";
cout<<-n<<" "<<-n<<" ";
for (int i=1; i<n; i+=2)cout<<m<<" "<<-n<<" ";
cout<<'\n';
continue;
}
if(m==n+1||m==n+2){
cout<<n*2-1<<'\n';
for (int i=1; i<n; i++)cout<<"2 ";
cout<<-2*n+1;
for (int i=1; i<n; i++)cout<<" 2";
cout<<'\n';
continue;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23788 KB |
Ok |
2 |
Correct |
14 ms |
23788 KB |
Ok |
3 |
Correct |
16 ms |
23788 KB |
Ok |
4 |
Correct |
14 ms |
23788 KB |
Ok |
5 |
Correct |
16 ms |
23788 KB |
Ok |
6 |
Correct |
15 ms |
23788 KB |
Ok |
7 |
Correct |
14 ms |
23788 KB |
Ok |
8 |
Correct |
15 ms |
23788 KB |
Ok |
9 |
Correct |
17 ms |
23788 KB |
Ok |
10 |
Correct |
14 ms |
23788 KB |
Ok |
11 |
Correct |
15 ms |
23788 KB |
Ok |
12 |
Correct |
16 ms |
23788 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23788 KB |
Ok |
2 |
Correct |
15 ms |
23788 KB |
Ok |
3 |
Correct |
14 ms |
23788 KB |
Ok |
4 |
Correct |
16 ms |
23788 KB |
Ok |
5 |
Correct |
55 ms |
23788 KB |
Ok |
6 |
Correct |
53 ms |
23916 KB |
Ok |
7 |
Correct |
18 ms |
24428 KB |
Ok |
8 |
Correct |
18 ms |
24120 KB |
Ok |
9 |
Correct |
19 ms |
24556 KB |
Ok |
10 |
Correct |
17 ms |
24172 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23788 KB |
Ok |
2 |
Correct |
15 ms |
23788 KB |
Ok |
3 |
Correct |
19 ms |
23788 KB |
Ok |
4 |
Incorrect |
15 ms |
23788 KB |
Jury has the better answer : jans = 9, pans = 2 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23788 KB |
Ok |
2 |
Correct |
15 ms |
23788 KB |
Ok |
3 |
Correct |
17 ms |
23788 KB |
Ok |
4 |
Correct |
17 ms |
23788 KB |
Ok |
5 |
Correct |
16 ms |
23788 KB |
Ok |
6 |
Correct |
55 ms |
26732 KB |
Ok |
7 |
Correct |
44 ms |
25964 KB |
Ok |
8 |
Correct |
72 ms |
28140 KB |
Ok |
9 |
Correct |
83 ms |
28560 KB |
Ok |
10 |
Correct |
49 ms |
25324 KB |
Ok |
11 |
Correct |
68 ms |
27472 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23788 KB |
Ok |
2 |
Correct |
14 ms |
23788 KB |
Ok |
3 |
Correct |
16 ms |
23788 KB |
Ok |
4 |
Correct |
14 ms |
23788 KB |
Ok |
5 |
Correct |
16 ms |
23788 KB |
Ok |
6 |
Correct |
15 ms |
23788 KB |
Ok |
7 |
Correct |
14 ms |
23788 KB |
Ok |
8 |
Correct |
15 ms |
23788 KB |
Ok |
9 |
Correct |
17 ms |
23788 KB |
Ok |
10 |
Correct |
14 ms |
23788 KB |
Ok |
11 |
Correct |
15 ms |
23788 KB |
Ok |
12 |
Correct |
16 ms |
23788 KB |
Ok |
13 |
Correct |
15 ms |
23788 KB |
Ok |
14 |
Correct |
15 ms |
23788 KB |
Ok |
15 |
Correct |
19 ms |
23788 KB |
Ok |
16 |
Incorrect |
15 ms |
23788 KB |
Jury has the better answer : jans = 9, pans = 2 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23788 KB |
Ok |
2 |
Correct |
14 ms |
23788 KB |
Ok |
3 |
Correct |
16 ms |
23788 KB |
Ok |
4 |
Correct |
14 ms |
23788 KB |
Ok |
5 |
Correct |
16 ms |
23788 KB |
Ok |
6 |
Correct |
15 ms |
23788 KB |
Ok |
7 |
Correct |
14 ms |
23788 KB |
Ok |
8 |
Correct |
15 ms |
23788 KB |
Ok |
9 |
Correct |
17 ms |
23788 KB |
Ok |
10 |
Correct |
14 ms |
23788 KB |
Ok |
11 |
Correct |
15 ms |
23788 KB |
Ok |
12 |
Correct |
16 ms |
23788 KB |
Ok |
13 |
Correct |
15 ms |
23788 KB |
Ok |
14 |
Correct |
15 ms |
23788 KB |
Ok |
15 |
Correct |
14 ms |
23788 KB |
Ok |
16 |
Correct |
16 ms |
23788 KB |
Ok |
17 |
Correct |
55 ms |
23788 KB |
Ok |
18 |
Correct |
53 ms |
23916 KB |
Ok |
19 |
Correct |
18 ms |
24428 KB |
Ok |
20 |
Correct |
18 ms |
24120 KB |
Ok |
21 |
Correct |
19 ms |
24556 KB |
Ok |
22 |
Correct |
17 ms |
24172 KB |
Ok |
23 |
Correct |
15 ms |
23788 KB |
Ok |
24 |
Correct |
15 ms |
23788 KB |
Ok |
25 |
Correct |
19 ms |
23788 KB |
Ok |
26 |
Incorrect |
15 ms |
23788 KB |
Jury has the better answer : jans = 9, pans = 2 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23788 KB |
Ok |
2 |
Correct |
14 ms |
23788 KB |
Ok |
3 |
Correct |
16 ms |
23788 KB |
Ok |
4 |
Correct |
14 ms |
23788 KB |
Ok |
5 |
Correct |
16 ms |
23788 KB |
Ok |
6 |
Correct |
15 ms |
23788 KB |
Ok |
7 |
Correct |
14 ms |
23788 KB |
Ok |
8 |
Correct |
15 ms |
23788 KB |
Ok |
9 |
Correct |
17 ms |
23788 KB |
Ok |
10 |
Correct |
14 ms |
23788 KB |
Ok |
11 |
Correct |
15 ms |
23788 KB |
Ok |
12 |
Correct |
16 ms |
23788 KB |
Ok |
13 |
Correct |
15 ms |
23788 KB |
Ok |
14 |
Correct |
15 ms |
23788 KB |
Ok |
15 |
Correct |
14 ms |
23788 KB |
Ok |
16 |
Correct |
16 ms |
23788 KB |
Ok |
17 |
Correct |
55 ms |
23788 KB |
Ok |
18 |
Correct |
53 ms |
23916 KB |
Ok |
19 |
Correct |
18 ms |
24428 KB |
Ok |
20 |
Correct |
18 ms |
24120 KB |
Ok |
21 |
Correct |
19 ms |
24556 KB |
Ok |
22 |
Correct |
17 ms |
24172 KB |
Ok |
23 |
Correct |
15 ms |
23788 KB |
Ok |
24 |
Correct |
15 ms |
23788 KB |
Ok |
25 |
Correct |
19 ms |
23788 KB |
Ok |
26 |
Incorrect |
15 ms |
23788 KB |
Jury has the better answer : jans = 9, pans = 2 |
27 |
Halted |
0 ms |
0 KB |
- |