Submission #909834

#TimeUsernameProblemLanguageResultExecution timeMemory
909834daoquanglinh2007Nice sequence (IZhO18_sequence)C++17
15 / 100
7 ms1116 KiB
#include <bits/stdc++.h> using namespace std; int T, N, M; vector <int> v; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> T; while (T--){ cin >> N >> M; if (N == M){ cout << N-1 << '\n'; for (int i = 1; i < N; i++) cout << 1 << ' '; cout << '\n'; continue; } if (N == 1){ cout << M-1 << '\n'; for (int i = 1; i < M; i++) cout << -1 << ' '; cout << '\n'; continue; } if (M == 1){ cout << N-1 << '\n'; for (int i = 1; i < N; i++) cout << 1 << ' '; cout << '\n'; continue; } bool rev = 0; if (N > M){ rev = 1; swap(N, M); } while (M%N != 1) M--; cout << M+N-2 << '\n'; int d = M/N+1; v.clear(); for (int i = 1; i <= M+N-2; i++) if (i%N == 0) v.push_back(-(N-1)*d-1); else v.push_back(d); if (rev){ for (int &x : v) x = -x; } for (int x : v) cout << x << ' '; cout << '\n'; } 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...