Submission #343627

# Submission time Handle Problem Language Result Execution time Memory
343627 2021-01-04T09:53:41 Z koketsu Nice sequence (IZhO18_sequence) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int LL

using namespace std;

const LL Mxn = 5e3;
const LL Mod = 1e9 + 7;
const LL Inf = 1e14 + 7;

signed main()
{
    Kultivator;
    int tt;
    cin >> tt;
    while(tt--)
    {
        int N, M;
        cin >> N >> M;
        if(N == M && N == 1)
        {
            cout << 0 << '\n';
        } else if(N == M){
            cout << max(N, M) - 1 << '\n';
            for(int i = 1; i < N; i++)
            {
                cout << -1 << ' ';
            }
        }
        else if(min(N, M) == 1)
        {
            cout << max(N, M) - 1 << '\n';
            for(int i = 1; i < max(N, M); i++)
            {
                if(N < M)
                {
                    cout << -1 << ' ';
                }
                else
                {
                    cout << 1 << ' ';
                }
            }
        }
        else if(min(N, M) == 2)
        {
            if(max(N, M) % 2)
            {
                cout << max(N, M) << '\n';
                if(N < M)
                {
                    cout << Mod - 1 << ' ';
                    for(int i = 1; i < M - 1; i++)
                    {
                        if(i % 2)
                        {
                            cout << -Mod << ' ';
                        }
                        else
                        {
                            cout << Mod - 1 << ' ';
                        }
                    }
                    cout << Mod - 1 << ' ';
                }
                else
                {
                    cout << -Mod + 1 << ' ';
                    for(int i = 1; i < N - 1; i++)
                    {
                        if(i % 2)
                        {
                            cout << Mod << ' ';
                        }
                        else
                        {
                            cout << -Mod + 1 << ' ';
                        }
                    }
                    cout << -Mod + 1 << ' ';
                }
            } else {
                cout << max(N, M) - 1 << '\n';
                if(N > M){
                    for(int i = 1; i < N; i++){
                        cout << 1 << ' ';
                    }
                } else {
                    for(int i = 1; i < M; i++){
                        cout << -1 << ' ';
                    }
                }
            }
        }
        else if(abs(N - M) == 1)
        {
            cout << max(N, M) << '\n';
            if(N < M)
            {
                cout << ((max(N, M) - 2) * Mxn) - 1 << ' ';
                for(int i = 1; i < M - 1; i++)
                {
                    cout << -Mxn << ' ';
                }
                cout << ((max(N, M) - 2) * Mxn) - 1 << ' ';
            }
            else
            {
                cout << ((max(N, M) - 2) * (-Mxn)) + 1 << ' ';
                for(int i = 1; i < N - 1; i++)
                {
                    cout << Mxn << ' ';
                }
                cout << ((max(N, M) - 2) * (-Mxn)) + 1 << ' ';
            }
        } else {
            if(N < M)
            {
                cout << ((max(N, M) - 3) * Mxn) - 1 << ' ';
                for(int i = 1; i < M - 1; i++)
                {
                    cout << -Mxn << ' ';
                }
                cout << ((max(N, M) - 3) * Mxn) - 1 << ' ';
            }
            else
            {
                cout << ((max(N, M) - 3) * (-Mxn)) + 1 << ' ';
                for(int i = 1; i < N - 1; i++)
                {
                    cout << Mxn << ' ';
                }
                cout << ((max(N, M) - 3) * (-Mxn)) + 1 << ' ';
            }
        }
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Incorrect 0 ms 364 KB Jury has the better answer : jans = 86, pans = -419999
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Absolute value of -1000000006 bigger than 1000000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Absolute value of 1000000006 bigger than 1000000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Absolute value of 1000000006 bigger than 1000000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Incorrect 0 ms 364 KB Jury has the better answer : jans = 86, pans = -419999
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Incorrect 0 ms 364 KB Jury has the better answer : jans = 86, pans = -419999
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Incorrect 0 ms 364 KB Jury has the better answer : jans = 86, pans = -419999
3 Halted 0 ms 0 KB -