답안 #1114117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114117 2024-11-18T08:10:09 Z vjudge1 Nice sequence (IZhO18_sequence) C++17
9 / 100
7 ms 1428 KB
#include <bits/stdc++.h>

using i64 = long long;

#ifdef DEBUG 
    #include "/home/ahmetalp/Desktop/Workplace/debug.h"
#else
    #define debug(...) void(23)
#endif

constexpr int INF = int(1E9) - 5;
constexpr int C = 1000;

void print(bool s, std::vector<int> x) {
    int n = int(x.size());
    std::cout << n << '\n';
    for (int i = 0; i < n; ++i) {
        std::cout << (s ? -1 : +1) * x[i] << " \n"[i == n - 1];
    }
}

void solve() {
    int N, M;
    std::cin >> N >> M;

    bool swapped = false;
    if (N < M) {
        swapped = true;
        std::swap(N, M);
    }

    if (M == 1) {
        std::vector<int> p(N - 1);
        for (int i = 0; i < N - 1; ++i) {
            p[i] = 1;
        }
        print(swapped, p);
    } else if (M == 2) {
        int len = ((N + M - 1) / M) * M - 1;
        std::vector<int> p(len);
        int x = INF / (M - 1);
        for (int i = 0; i < M - 1; ++i) {
            p[i] = -x;
        }
        if (M - 1 < len) {
            p[M - 1] = x * (M - 1) + 1;
        }
        for (int i = M; i < len; ++i) {
            p[i] = p[i % M];
        }
        print(swapped, p);
    } else {
        int len = ((N + M - 1) / M) * M;
        std::vector<int> p(len);
        int posx = INF / (M - 2);
        for (int i = 0; i < M - 2; ++i) {
            p[i] = posx;
        }
        int negx = posx * (M - 2) - C;
        p[M - 2] = -negx;
        p[M - 1] = 3 * C;
        for (int i = M; i < len; ++i) {
            p[i] = p[i % M];
        }
        print(swapped, p);
    }
    
    return;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int TT = 1; std::cin >> TT;
    for (int i = 1; i <= TT; ++i) {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Ok
2 Incorrect 1 ms 336 KB there is incorrect sequence
3 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 2 ms 592 KB Ok
7 Correct 6 ms 1360 KB Ok
8 Correct 3 ms 848 KB Ok
9 Correct 7 ms 1428 KB Ok
10 Correct 5 ms 848 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Ok
2 Correct 1 ms 380 KB Ok
3 Correct 1 ms 336 KB Ok
4 Incorrect 1 ms 336 KB there is incorrect sequence
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 1 ms 336 KB there is incorrect sequence
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Ok
2 Incorrect 1 ms 336 KB there is incorrect sequence
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Ok
2 Incorrect 1 ms 336 KB there is incorrect sequence
3 Halted 0 ms 0 KB -