답안 #107155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107155 2019-04-22T08:23:36 Z Shafin666 Nice sequence (IZhO18_sequence) C++14
6 / 100
3 ms 384 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<ll, ll>
#define  read_input         freopen("in.txt","r", stdin)
#define  print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;

int a[200005];

int main()
{   
    //read_input;
    //print_output;

    int tc, p = 2e5+10;
    cin >> tc;

    while(tc--) {
        int n, m; int mul = 1;
        cin >> n >> m;

        if(m < n) mul *= -1, swap(n, m);

        int delta = m-n;

        if(delta*2 >= m || n == 1 || m == 1 || n == m) {
            if(n == 1 && m == 1) {cout << 0 << endl; continue;}

            if(2*n+1 == m && m == 5) {
                cout << m << endl;
                for(int i = 1; i <= m; i++) {
                    if(i & 1) cout << 3*mul << " ";
                    else cout << -4*mul << " ";
                }
                cout << endl;
                continue;
            }

            cout << m-1 << endl;
            for(int i = 1; i < m; i++) cout << -1*mul << " "; cout << endl;

            continue;
        }

        cout << m << endl;

        for(int i = 1; i <= delta; i++) a[i] = p * mul;
        for(int i = m; i > m-delta; i--) a[i] = p * mul;

        

        int total = delta * p * 2 - 1, left = m - 2*delta;
        
        for(int i = delta+1; i < m-delta; i++) a[i] = total/left * -1 * mul;
        a[m-delta] = -1 * (total - (total/left)*(left-1)) * mul;

        for(int i = 1; i <= m; i++) cout << a[i] << " "; cout <<endl;
    }

    return 0;   
} 

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:43:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
             for(int i = 1; i < m; i++) cout << -1*mul << " "; cout << endl;
             ^~~
sequence.cpp:43:63: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             for(int i = 1; i < m; i++) cout << -1*mul << " "; cout << endl;
                                                               ^~~~
sequence.cpp:60:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(int i = 1; i <= m; i++) cout << a[i] << " "; cout <<endl;
         ^~~
sequence.cpp:60:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         for(int i = 1; i <= m; i++) cout << a[i] << " "; cout <<endl;
                                                          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 384 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 256 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 3 ms 256 KB Ok
10 Correct 2 ms 384 KB Ok
11 Correct 2 ms 384 KB Ok
12 Correct 2 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Jury has the better answer : jans = 7, pans = 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 256 KB Ok
3 Incorrect 2 ms 256 KB Jury has the better answer : jans = 7, pans = 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 304 KB Jury has the better answer : jans = 5, pans = 4
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 384 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 256 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 3 ms 256 KB Ok
10 Correct 2 ms 384 KB Ok
11 Correct 2 ms 384 KB Ok
12 Correct 2 ms 384 KB Ok
13 Correct 2 ms 256 KB Ok
14 Correct 2 ms 256 KB Ok
15 Incorrect 2 ms 256 KB Jury has the better answer : jans = 7, pans = 6
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 384 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 256 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 3 ms 256 KB Ok
10 Correct 2 ms 384 KB Ok
11 Correct 2 ms 384 KB Ok
12 Correct 2 ms 384 KB Ok
13 Incorrect 2 ms 384 KB Jury has the better answer : jans = 7, pans = 6
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 384 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 256 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 3 ms 256 KB Ok
10 Correct 2 ms 384 KB Ok
11 Correct 2 ms 384 KB Ok
12 Correct 2 ms 384 KB Ok
13 Incorrect 2 ms 384 KB Jury has the better answer : jans = 7, pans = 6
14 Halted 0 ms 0 KB -