Submission #1109255

# Submission time Handle Problem Language Result Execution time Memory
1109255 2024-11-06T09:26:36 Z Muhammet Nice sequence (IZhO18_sequence) C++17
0 / 100
996 ms 584 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int n1, n, m;

bool tr;

vector <ll> a, p;

void f(int x){
	if(tr == 1) return;
	if(x == n1+1){
		for(int i = 1; i <= n1; i++){
			p[i] = p[i-1] + a[i];
		}
		bool tr1 = 0;
		for(int i = 1; i <= n1; i++){
			if(i >= m){
				if(p[i] <= p[i-m]){
					tr1 = 1;
					break;
				}
			}
			if(i >= n){
				if(p[i] >= p[i-n]){
					tr1 = 1;
					break;
				}
			}
		}
		if(tr1 == 0){
			tr = 1;
			cout << n1 << '\n';
			for(int i = 1;  i <= n1; i++){
				cout << a[i] << ' ';
			}
			cout << '\n';
		}
		return;
	}
	a[x] = (n < m ? (n + m) : -(n + m));
	f(x+1);
	a[x] = (n < m ? -(n + m + 1) : (n + m + 1));
	f(x+1);
}

int main(){
	int t;
	cin >> t;
	while(t--){
		cin >> n >> m;
		a.resize(25);
		p.assign(25,0);
		for(int i = (20); i >= 1; i--){
			tr = 0;
			n1 = i;
			f(1);
			if(tr) break;
		}
		if(tr == 0){
			cout << 0 << "\n";
		}
		// cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 873 ms 336 KB Jury has the better answer : jans = 99, pans = 20
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 976 ms 336 KB Ok
2 Incorrect 810 ms 336 KB Jury has the better answer : jans = 21, pans = 20
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 278 ms 420 KB Ok
2 Correct 922 ms 336 KB Ok
3 Correct 970 ms 584 KB Ok
4 Incorrect 963 ms 420 KB Jury has the better answer : jans = 9, pans = 7
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 996 ms 336 KB Jury has the better answer : jans = 5, pans = 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 873 ms 336 KB Jury has the better answer : jans = 99, pans = 20
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 873 ms 336 KB Jury has the better answer : jans = 99, pans = 20
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 873 ms 336 KB Jury has the better answer : jans = 99, pans = 20
2 Halted 0 ms 0 KB -