Submission #1114050

# Submission time Handle Problem Language Result Execution time Memory
1114050 2024-11-18T07:09:28 Z vjudge1 Nice sequence (IZhO18_sequence) C++17
15 / 100
6 ms 848 KB
#include <bits/stdc++.h>
#define pb push_back
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<long long,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define mid (l+r)/2
#define inf 1e15
#define MOD 998244353
#define MX 100000
using namespace std;


void solve(){
    int n,m; cin >> n >> m;//assuming m is bigger
    int modi=1;
    if(n>m){
        modi=-1;
        swap(n,m);
    }
    int wow=n*((m-1)/n+1)-1;
    if(n==m || m-1>=wow){
        cout << m-1 << endl;
        if(m-1==0) return;
        for(int i=1; i<=m-1; i++){
            cout << -modi << " ";
        }
        cout << endl;
    }
    else{
        cout << wow << endl;
        if(wow==0) return;
        for(int i=1; i<=wow; i++){
            if(i%n==0) cout << -modi*((m-1)/n+1)*(n-1)-modi << " ";
            else cout << ((m-1)/n+1)*modi << " ";
        }
        cout << endl;
    }
}


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    /*#else
    freopen("248.in","r",stdin);
    freopen("248.out","w",stdout);*/
    #endif


    int t=1;
    cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 336 KB Ok
3 Correct 1 ms 336 KB Ok
4 Correct 1 ms 336 KB Ok
5 Correct 1 ms 336 KB Ok
6 Correct 2 ms 336 KB Ok
7 Correct 1 ms 336 KB Ok
8 Correct 1 ms 336 KB Ok
9 Correct 1 ms 336 KB Ok
10 Correct 2 ms 336 KB Ok
11 Correct 1 ms 336 KB Ok
12 Correct 1 ms 336 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 336 KB Ok
3 Correct 1 ms 336 KB Ok
4 Correct 1 ms 336 KB Ok
5 Correct 1 ms 336 KB Ok
6 Correct 2 ms 336 KB Ok
7 Correct 5 ms 592 KB Ok
8 Correct 3 ms 592 KB Ok
9 Correct 6 ms 848 KB Ok
10 Correct 4 ms 592 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 336 KB Ok
3 Correct 1 ms 336 KB Ok
4 Incorrect 1 ms 336 KB Jury has the better answer : jans = 9, pans = 8
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Jury has the better answer : jans = 6, pans = 5
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 336 KB Ok
3 Correct 1 ms 336 KB Ok
4 Correct 1 ms 336 KB Ok
5 Correct 1 ms 336 KB Ok
6 Correct 2 ms 336 KB Ok
7 Correct 1 ms 336 KB Ok
8 Correct 1 ms 336 KB Ok
9 Correct 1 ms 336 KB Ok
10 Correct 2 ms 336 KB Ok
11 Correct 1 ms 336 KB Ok
12 Correct 1 ms 336 KB Ok
13 Correct 1 ms 336 KB Ok
14 Correct 1 ms 336 KB Ok
15 Correct 1 ms 336 KB Ok
16 Incorrect 1 ms 336 KB Jury has the better answer : jans = 9, pans = 8
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 336 KB Ok
3 Correct 1 ms 336 KB Ok
4 Correct 1 ms 336 KB Ok
5 Correct 1 ms 336 KB Ok
6 Correct 2 ms 336 KB Ok
7 Correct 1 ms 336 KB Ok
8 Correct 1 ms 336 KB Ok
9 Correct 1 ms 336 KB Ok
10 Correct 2 ms 336 KB Ok
11 Correct 1 ms 336 KB Ok
12 Correct 1 ms 336 KB Ok
13 Correct 1 ms 336 KB Ok
14 Correct 1 ms 336 KB Ok
15 Correct 1 ms 336 KB Ok
16 Correct 1 ms 336 KB Ok
17 Correct 1 ms 336 KB Ok
18 Correct 2 ms 336 KB Ok
19 Correct 5 ms 592 KB Ok
20 Correct 3 ms 592 KB Ok
21 Correct 6 ms 848 KB Ok
22 Correct 4 ms 592 KB Ok
23 Correct 1 ms 336 KB Ok
24 Correct 1 ms 336 KB Ok
25 Correct 1 ms 336 KB Ok
26 Incorrect 1 ms 336 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 336 KB Ok
3 Correct 1 ms 336 KB Ok
4 Correct 1 ms 336 KB Ok
5 Correct 1 ms 336 KB Ok
6 Correct 2 ms 336 KB Ok
7 Correct 1 ms 336 KB Ok
8 Correct 1 ms 336 KB Ok
9 Correct 1 ms 336 KB Ok
10 Correct 2 ms 336 KB Ok
11 Correct 1 ms 336 KB Ok
12 Correct 1 ms 336 KB Ok
13 Correct 1 ms 336 KB Ok
14 Correct 1 ms 336 KB Ok
15 Correct 1 ms 336 KB Ok
16 Correct 1 ms 336 KB Ok
17 Correct 1 ms 336 KB Ok
18 Correct 2 ms 336 KB Ok
19 Correct 5 ms 592 KB Ok
20 Correct 3 ms 592 KB Ok
21 Correct 6 ms 848 KB Ok
22 Correct 4 ms 592 KB Ok
23 Correct 1 ms 336 KB Ok
24 Correct 1 ms 336 KB Ok
25 Correct 1 ms 336 KB Ok
26 Incorrect 1 ms 336 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -