Submission #379009

#TimeUsernameProblemLanguageResultExecution timeMemory
379009casperwangNice sequence (IZhO18_sequence)C++14
6 / 100
2 ms492 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; const int INF = 1e8; const int K = 2e6; int t; int n, m; bool flag; int len; int a[MAXN+1]; void solve(int n, int m) { if (m % n == 0) { len = m-1; for (int i = 1; i <= len; i++) a[i] = flag ? 1 : -1; } else { len = (m + n-1) / n * n - 1; for (int i = 1; i <= len; i++) { if (i % n == 1 && i != 1) a[i] = flag ? -INF : INF; else if (i == n-1) a[i] = flag ? -INF : INF; else if (i % n == 0) a[i] = flag ? INF+K : -INF-K; else a[i] = 1; } } } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); /* for (int i = 1; i <= 10; i++) for (int j = i; j <= 10; j++) solve(i, j), debug(i, j, len); return 0; */ cin >> t; while (t--) { cin >> n >> m; if (n > m) swap(n, m), flag = true; else flag = false; solve(n, m); 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...