Submission #877070

# Submission time Handle Problem Language Result Execution time Memory
877070 2023-11-22T20:13:55 Z auslander Nice sequence (IZhO18_sequence) C++17
6 / 100
1 ms 352 KB
#include <iostream>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <string>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <vector>
#include <iterator>
using namespace std;

//defines
#define ll long long
#define usg unsigned
#define kap map
#define print(x, n) for(int for_loop = 0; for_loop < n; for_loop++){cout<<x[for_loop]<<' ';}cout<<endl; 
#define read(x, n) for(int for_loop = 0; for_loop < n; for_loop++){cin>>x[for_loop];} 
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ratdig(x) cout << fixed << setprecision(x);
#define xfixdig(x) cout << setprecision(x);
#define multi int t; cin>>t; presolve(); while(t--) solve()
#define single presolve(); solve(); return 0
#define rev(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()

//functions
void yn(bool b)
{
	if (b)
	{
		cout << "YES\n";
		return;
	}
	cout << "NO\n";
}

ll gcd(ll a, ll b) {
	if (a == 0)
		return b;
	if (b == 0)
		return a;
	return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
	return (a * b) / gcd(a, b);
}

string to2(ll a)
{
	string r = "";
	for (ll i = a; i > 0; )
	{
		ll k = i % 2;
		i /= 2;
		char c = k + 48;
		r += c;
	}
	if (a == 0)
	{
		r = "0";
	}
	rev(r);

	return r;
}

ll binpow(ll a, ll b, ll mod = -1)
{
	ll ans = 1;
	while (b)
	{
		if ((b & 1) == 1)
		{
			ans *= a;
			if (mod != -1)
				ans %= mod;
		}
		b >>= 1;
		a *= a;
		if (mod != -1)
			a %= mod;
	}
	return ans;
}

//body

void presolve()
{

}

void solve()
{
	ll i, j, n, m, k, s, t, x, y;
	cin >> n >> m;
	if (max(n, m) % min(m, n) == 0)
	{
		if (n < m)
		{
			cout << m - 1 << endl;
			for (i = 0; i < m - 1; i++)
			{
				cout << -i - 1 << ' ';
			}
			cout << endl;
		}
		else if (n == m)
		{
			cout << n - 1 << endl;
			for (i = 0; i < n - 1; i++)
			{
				cout << i + 1 << ' ';
			}
			cout << endl;
		}
		else
		{
			cout << n - 1 << endl;
			for (i = 0; i < n - 1; i++)
			{
				cout << i + 1 << ' ';
			}
			cout << endl;
		}
	}
	else if (min(n, m) == 2)
	{
		if (max(n, m) == 3)
		{
			cout << 3 << endl;
			cout << 3 << ' ' << -4 << ' ' << 2 << endl;
			return;
		}
		cout << max(n, m) - 1 << endl;
		if (n < m)
		{
			cout << m - 1 << endl;
			for (i = 0; i < m - 1; i++)
			{
				cout << -i - 1 << ' ';
			}
			cout << endl;
		}
		else if (n == m)
		{
			cout << n - 1 << endl;
			for (i = 0; i < n - 1; i++)
			{
				cout << i + 1 << ' ';
			}
			cout << endl;
		}
		else
		{
			cout << n - 1 << endl;
			for (i = 0; i < n - 1; i++)
			{
				cout << i + 1 << ' ';
			}
			cout << endl;
		}
	}
	else cout << 0 << endl;
}

int main()
{
	speed;
	//single;
	multi;

	return 0;
}

Compilation message

sequence.cpp: In function 'void solve()':
sequence.cpp:101:8: warning: unused variable 'j' [-Wunused-variable]
  101 |  ll i, j, n, m, k, s, t, x, y;
      |        ^
sequence.cpp:101:17: warning: unused variable 'k' [-Wunused-variable]
  101 |  ll i, j, n, m, k, s, t, x, y;
      |                 ^
sequence.cpp:101:20: warning: unused variable 's' [-Wunused-variable]
  101 |  ll i, j, n, m, k, s, t, x, y;
      |                    ^
sequence.cpp:101:23: warning: unused variable 't' [-Wunused-variable]
  101 |  ll i, j, n, m, k, s, t, x, y;
      |                       ^
sequence.cpp:101:26: warning: unused variable 'x' [-Wunused-variable]
  101 |  ll i, j, n, m, k, s, t, x, y;
      |                          ^
sequence.cpp:101:29: warning: unused variable 'y' [-Wunused-variable]
  101 |  ll i, j, n, m, k, s, t, x, y;
      |                             ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 344 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 352 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Incorrect 0 ms 348 KB Jury has the better answer : jans = 5, pans = 4
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Jury has the better answer : jans = 5, pans = 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 344 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 0 ms 348 KB Ok
13 Correct 0 ms 348 KB Ok
14 Correct 0 ms 348 KB Ok
15 Incorrect 0 ms 348 KB Jury has the better answer : jans = 5, pans = 4
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 344 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 0 ms 348 KB Ok
13 Incorrect 0 ms 352 KB there is incorrect sequence
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
9 Correct 0 ms 344 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 0 ms 348 KB Ok
13 Incorrect 0 ms 352 KB there is incorrect sequence
14 Halted 0 ms 0 KB -