제출 #1114102

#제출 시각아이디문제언어결과실행 시간메모리
1114102vjudge1Nice sequence (IZhO18_sequence)C++17
9 / 100
12 ms1528 KiB
#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; 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 { 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; } p[M - 1] = x * (M - 1) + 1; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...