답안 #1114115

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114115 2024-11-18T08:07:47 Z vjudge1 Nice sequence (IZhO18_sequence) C++17
6 / 100
2 ms 336 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 x=(m-1)/n;
    int wow=x+1+x*(n-1)+2*(m-n-1);
    if(m%n==0 || 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;
        int B=-x-2, A=-1-(n-1)*B;
        for(int i=1; i<=m-n-1; i++){
            cout << modi*B << " ";
        }
        for(int i=0; i<wow-2*(m-n-1); i++){
            if(i%n==0){
                cout << modi*A << " ";
            }
            else cout << modi*B << " ";
        }
        for(int i=1; i<=m-n-1; i++){
            cout << modi*B << " ";
        }
        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();
}
# 결과 실행 시간 메모리 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 1 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 1 ms 336 KB Ok
11 Correct 1 ms 336 KB Ok
12 Correct 1 ms 336 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 336 KB Ok
3 Incorrect 1 ms 336 KB there is incorrect sequence
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 336 KB Jury has the better answer : jans = 5, pans = 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 1 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 Incorrect 1 ms 336 KB there is incorrect sequence
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 1 ms 336 KB Ok
11 Correct 1 ms 336 KB Ok
12 Correct 1 ms 336 KB Ok
13 Incorrect 1 ms 336 KB there is incorrect sequence
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 1 ms 336 KB Ok
11 Correct 1 ms 336 KB Ok
12 Correct 1 ms 336 KB Ok
13 Incorrect 1 ms 336 KB there is incorrect sequence
14 Halted 0 ms 0 KB -