답안 #91931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91931 2018-12-31T14:12:45 Z popovicirobert Nice sequence (IZhO18_sequence) C++14
15 / 100
9 ms 1016 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int INF = 999999999;
const int MAXN = (int) 2e5;

int arr[2 * MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int t, i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while(t > 0) {
        t--;
        int n, m;
        cin >> n >> m;
        int mn = min(n, m), mx = max(n, m);
        if(mx % mn == 0) {
            cout << mx - 1 << "\n";
            int sign = 1;
            if(mn == n) {
                sign = -1;
            }
            for(i = 1; i < mx; i++) {
                cout << sign << " ";
            }
            cout << "\n";
            continue;
        }
        int sz = n + m - 2, val = INF / (mn - 1);
        int pos = 1;
        cout << sz << "\n";
        while(pos <= sz) {
            for(i = 1; i <= mn - 1 && pos <= sz; i++) {
                arr[pos] = val;
                pos++;
            }
            if(pos <= sz) {
                arr[pos] = - val * (mn - 1) - 1;
                pos++;
            }
        }
        int sign = 1;
        if(n != mn) {
            sign = -1;
        }
        for(i = 1; i <= sz; i++) {
            cout << sign * arr[i] << " ";
        }
        cout << "\n";
    }
    //cin.close();
    //cout.close();
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 376 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 376 KB Ok
11 Correct 2 ms 376 KB Ok
12 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 3 ms 380 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 3 ms 504 KB Ok
7 Correct 7 ms 888 KB Ok
8 Correct 5 ms 632 KB Ok
9 Correct 9 ms 1016 KB Ok
10 Correct 6 ms 760 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 376 KB Ok
4 Incorrect 2 ms 376 KB there is incorrect sequence
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 376 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 376 KB Ok
11 Correct 2 ms 376 KB Ok
12 Correct 2 ms 376 KB Ok
13 Correct 2 ms 376 KB Ok
14 Correct 2 ms 376 KB Ok
15 Correct 2 ms 376 KB Ok
16 Incorrect 2 ms 376 KB there is incorrect sequence
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 376 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 376 KB Ok
11 Correct 2 ms 376 KB Ok
12 Correct 2 ms 376 KB Ok
13 Correct 2 ms 376 KB Ok
14 Correct 2 ms 376 KB Ok
15 Correct 3 ms 380 KB Ok
16 Correct 2 ms 376 KB Ok
17 Correct 2 ms 376 KB Ok
18 Correct 3 ms 504 KB Ok
19 Correct 7 ms 888 KB Ok
20 Correct 5 ms 632 KB Ok
21 Correct 9 ms 1016 KB Ok
22 Correct 6 ms 760 KB Ok
23 Correct 2 ms 376 KB Ok
24 Correct 2 ms 376 KB Ok
25 Correct 2 ms 376 KB Ok
26 Incorrect 2 ms 376 KB there is incorrect sequence
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 376 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 376 KB Ok
11 Correct 2 ms 376 KB Ok
12 Correct 2 ms 376 KB Ok
13 Correct 2 ms 376 KB Ok
14 Correct 2 ms 376 KB Ok
15 Correct 3 ms 380 KB Ok
16 Correct 2 ms 376 KB Ok
17 Correct 2 ms 376 KB Ok
18 Correct 3 ms 504 KB Ok
19 Correct 7 ms 888 KB Ok
20 Correct 5 ms 632 KB Ok
21 Correct 9 ms 1016 KB Ok
22 Correct 6 ms 760 KB Ok
23 Correct 2 ms 376 KB Ok
24 Correct 2 ms 376 KB Ok
25 Correct 2 ms 376 KB Ok
26 Incorrect 2 ms 376 KB there is incorrect sequence
27 Halted 0 ms 0 KB -