답안 #909828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909828 2024-01-17T13:02:24 Z daoquanglinh2007 Nice sequence (IZhO18_sequence) C++17
6 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

const int F = 1e6;

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*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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 1 ms 348 KB Ok
3 Correct 1 ms 604 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 1 ms 456 KB Ok
7 Correct 1 ms 348 KB Ok
8 Correct 1 ms 348 KB Ok
9 Correct 1 ms 348 KB Ok
10 Correct 0 ms 348 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 1 ms 348 KB Ok
3 Correct 1 ms 604 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 1 ms 456 KB Ok
7 Correct 1 ms 348 KB Ok
8 Correct 1 ms 348 KB Ok
9 Correct 1 ms 348 KB Ok
10 Correct 0 ms 348 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
13 Incorrect 1 ms 348 KB there is incorrect sequence
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 1 ms 348 KB Ok
3 Correct 1 ms 604 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 1 ms 456 KB Ok
7 Correct 1 ms 348 KB Ok
8 Correct 1 ms 348 KB Ok
9 Correct 1 ms 348 KB Ok
10 Correct 0 ms 348 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
13 Incorrect 1 ms 348 KB there is incorrect sequence
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 1 ms 348 KB Ok
3 Correct 1 ms 604 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 1 ms 456 KB Ok
7 Correct 1 ms 348 KB Ok
8 Correct 1 ms 348 KB Ok
9 Correct 1 ms 348 KB Ok
10 Correct 0 ms 348 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
13 Incorrect 1 ms 348 KB there is incorrect sequence
14 Halted 0 ms 0 KB -