Submission #378949

#TimeUsernameProblemLanguageResultExecution timeMemory
378949casperwangNice sequence (IZhO18_sequence)C++14
15 / 100
11 ms748 KiB
#include <bits/stdc++.h> using namespace std; #define debug(args...) kout("[ " + string(#args) + " ]", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); } template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; } const int MAXN = 200000; int t; int n, m; bool flag; int len; int a[MAXN+1]; void solve() { if (m % n == 0) { len = m-1; for (int i = 1; i <= len; i++) a[i] = flag ? 1 : -1; } else if (n == 2) { len = m; for (int i = 1; i <= len; i++) { if (i & 1) a[i] = flag ? -m/2-1 : m/2+1; else a[i] = flag ? m/2+2 : -m/2-2; } } } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> t; while (t--) { cin >> n >> m; if (n > m) swap(n, m), flag = true; else flag = false; solve(); cout << len << '\n'; for (int i = 1; i <= len; i++) cout << a[i] << " \n"[i==len]; } }
#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...