Submission #760570

# Submission time Handle Problem Language Result Execution time Memory
760570 2023-06-17T20:29:53 Z NK_ Nice sequence (IZhO18_sequence) C++17
9 / 100
8 ms 1732 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'
#define pb push_back

using ll = long long;
template<class T> using V = vector<T>;

const int MAX = 1e9;

void solve() {
	int N, M; cin >> N >> M;

	bool SWAP = 0; if (N < M) { swap(N, M); SWAP = 1; }
	// WLOG N > M

	int D = (N + M - 1) / M; int ans = D * M - 1; 
	V<ll> A(ans);
	// cout << ans << endl;
	int X = -(MAX - 1) / (M - 1);
	int REM = (MAX - 1) % (M - 1);
	// cout << REM << nl;
	// cout << X << nl;

	for(int i = 0; i < ans; i++) {
		if (i % M == M - 1) A[i] = MAX;
		else {
			// cout << i % M << " " << REM << endl;
			A[i] = ((i % M) < REM ? X - 1 : X);
		}
	}

	// cout << SWAP << nl;
	if (SWAP) {
		for(auto& x : A) x = -x;
		swap(N, M);
	}

	cout << ans << nl;
	for(auto& x : A) cout << x << " ";
	cout << nl;
	
	auto checker = [&]() {
		int K = size(A);
		V<ll> P = {0}; for(auto& x : A) P.pb(P.back() + x);

		for(int i = 0; i <= K; i++) {
			if (i >= N) {
				ll S = P[i] - P[i - N];
				// cout << i << " " << S << endl;
				assert(S < 0);
			}

			if (i >= M) {
				ll S = P[i] - P[i - M];
				// cout << i << " " << S << endl;
				assert(S > 0);
			}
		}
	};

	checker();

}	

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int T; cin >> T;
	while(T--) {
		solve();
	}

    return 0;
}


# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 1 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 2 ms 468 KB Ok
7 Correct 7 ms 1484 KB Ok
8 Correct 3 ms 852 KB Ok
9 Correct 8 ms 1732 KB Ok
10 Correct 5 ms 1076 KB Ok
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Jury has the better answer : jans = 6, pans = 5
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -