Submission #378933

#TimeUsernameProblemLanguageResultExecution timeMemory
378933fhvirusNice sequence (IZhO18_sequence)C++17
15 / 100
9 ms748 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second #define pb emplace_back #define AI(x) begin(x),end(x) template<typename I> bool chmax(I &a, I b){ return a < b ? (a = b, true) : false;} template<typename I> bool chmin(I &a, I b){ return a > b ? (a = b, true) : false;} #ifdef OWO #define debug(args...) LKJ("[ " + string(#args) + " ]", args) void LKJ(){ cerr<<endl;} template<class I, class...T> void LKJ(I x, T... t){ cerr<<x<<", ", LKJ(t...);} template<class I> void DE(I a, I b){ while(a < b) cerr<<*a<<" \n"[next(a) == b], ++a;} #else #define debug(...) 0 #define DE(...) 0 #endif void solve(){ int n, m; cin >> n >> m; int rev = 1; if(n < m) swap(n, m), rev = -1; if(n - 1 == 0){ cout << n - 1 << '\n'; return; } if(n % m == 0){ cout << n - 1 << '\n'; for(int i = 0; i < n - 1; ++i) cout << 1 * rev << ' '; cout << '\n'; return; } if(m == 2){ cout << n << '\n'; for(int i = 0; i < n; ++i){ if(i & 1) cout << ((n + 1) / 2 + 1) * rev << ' '; else cout << ((n + 1) / 2) * rev * -1 << ' '; } cout << '\n'; return; } } int32_t main(){ ios_base::sync_with_stdio(0); int t; cin >> t; for(; t; --t) 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...