Submission #379014

# Submission time Handle Problem Language Result Execution time Memory
379014 2021-03-17T08:25:58 Z casperwang Nice sequence (IZhO18_sequence) C++14
15 / 100
13 ms 1132 KB
#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 = 9e8;
int t;
int n, m;
int K;
bool flag;
int len;
int a[MAXN+1];

void solve(int n, int m) {
	K = n;
	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 time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 1 ms 364 KB Ok
8 Correct 1 ms 364 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 1 ms 364 KB Ok
12 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 2 ms 492 KB Ok
7 Correct 9 ms 1004 KB Ok
8 Correct 5 ms 620 KB Ok
9 Correct 13 ms 1132 KB Ok
10 Correct 6 ms 768 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Incorrect 1 ms 364 KB Jury has the better answer : jans = 9, pans = 8
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 1 ms 364 KB Ok
8 Correct 1 ms 364 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 1 ms 364 KB Ok
12 Correct 1 ms 364 KB Ok
13 Correct 1 ms 364 KB Ok
14 Correct 1 ms 364 KB Ok
15 Correct 1 ms 364 KB Ok
16 Incorrect 1 ms 364 KB Jury has the better answer : jans = 9, pans = 8
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 1 ms 364 KB Ok
8 Correct 1 ms 364 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 1 ms 364 KB Ok
12 Correct 1 ms 364 KB Ok
13 Correct 1 ms 384 KB Ok
14 Correct 1 ms 364 KB Ok
15 Correct 1 ms 364 KB Ok
16 Correct 1 ms 364 KB Ok
17 Correct 1 ms 364 KB Ok
18 Correct 2 ms 492 KB Ok
19 Correct 9 ms 1004 KB Ok
20 Correct 5 ms 620 KB Ok
21 Correct 13 ms 1132 KB Ok
22 Correct 6 ms 768 KB Ok
23 Correct 1 ms 364 KB Ok
24 Correct 1 ms 364 KB Ok
25 Correct 1 ms 364 KB Ok
26 Incorrect 1 ms 364 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 1 ms 364 KB Ok
8 Correct 1 ms 364 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 1 ms 364 KB Ok
12 Correct 1 ms 364 KB Ok
13 Correct 1 ms 384 KB Ok
14 Correct 1 ms 364 KB Ok
15 Correct 1 ms 364 KB Ok
16 Correct 1 ms 364 KB Ok
17 Correct 1 ms 364 KB Ok
18 Correct 2 ms 492 KB Ok
19 Correct 9 ms 1004 KB Ok
20 Correct 5 ms 620 KB Ok
21 Correct 13 ms 1132 KB Ok
22 Correct 6 ms 768 KB Ok
23 Correct 1 ms 364 KB Ok
24 Correct 1 ms 364 KB Ok
25 Correct 1 ms 364 KB Ok
26 Incorrect 1 ms 364 KB Jury has the better answer : jans = 9, pans = 8
27 Halted 0 ms 0 KB -