Submission #852611

# Submission time Handle Problem Language Result Execution time Memory
852611 2023-09-22T08:04:44 Z Mher777 Nice sequence (IZhO18_sequence) C++17
15 / 100
6 ms 1116 KB
//////////////////////////////// Mher777
/* -------------------- Includes -------------------- */
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <fstream>
#pragma warning(disable : 4996)
#pragma warning(disable : 6031)
using namespace std;

/* -------------------- Typedefs -------------------- */

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;
typedef float fl;
typedef double db;
typedef long double ld;

/* -------------------- Usings -------------------- */

using vi = vector<int>;
using vll = vector<ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* -------------------- Defines -------------------- */

#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mpr make_pair
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define all(x) (x).begin(), (x).end()

/* -------------------- Constants -------------------- */

const int MAX = int(1e9 + 5);
const ll MAXL = ll(1e18 + 5);
const ll MOD = ll(1e9 + 7);
const ll MOD2 = ll(998244353);

/* -------------------- Functions -------------------- */

void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    return;
}

void precision(int x) {
    cout.setf(ios::fixed | ios::showpoint);
    cout.precision(x);
    return;
}

ull gcd(ull a, ull b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

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

ll range_sum(ll a, ll b) {
    ll dif = a - 1, cnt = b - a + 1;
    ll ans = ((b - a + 1) * (b - a + 2)) / 2;
    ans += ((b - a + 1) * dif);
    return ans;
}

string dec_to_bin(ll a) {
    string s = "";
    for (ll i = a; i > 0; ) {
        ll k = i % 2;
        i /= 2;
        char c = k + 48;
        s += c;
    }
    if (a == 0) {
        s = "0";
    }
    reverse(all(s));
    return s;
}

ll bin_to_dec(string s) {
    ll num = 0;
    for (int i = 0; i < s.size(); i++) {
        num *= 2ll;
        num += (s[i] - '0');
    }
    return num;
}

bool isPrime(ll a) {
    if (a == 1) {
        return false;
    }
    for (ll i = 2; i * i <= a; i++) {
        if (a % i == 0) {
            return false;
        }
    }
    return true;
}

int dig_sum(ll a) {
    int sum = 0;
    while (a) {
        sum += int(a % 10);
        a /= 10;
    }
    return sum;
}

ll binpow(ll a, int b) {
    ll ans = 1;
    while (b) {
        if ((b & 1) == 1) {
            ans *= a;
        }
        b >>= 1;
        a *= a;
    }
    return ans;
}

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

ll factorial(int a) {
    ll ans = 1;
    for (int i = 2; i <= a; i++) {
        ans *= ll(i);
    }
    return ans;
}

ll factorial_by_mod(int a, ll mod) {
    ll ans = 1;
    for (int i = 2; i <= a; i++) {
        ans *= ll(i);
        ans %= mod;
    }
    return ans;
}

/* -------------------- Solution -------------------- */

void slv() {
    int n, m;
    cin >> n >> m;
    if (max(n, m) % min(n, m) == 0) {
        cout << max(n, m) - 1 << '\n';
        int num = (max(n, m) == n ? 1 : -1);
        for (int i = 1; i < max(n, m); i++) cout << num << " ";
        cout << '\n';
        return;
    }
    if (min(n, m) == 2) {
        ll mx = 999999999;
        cout << max(n, m) << '\n';
        if (min(n, m) == n) {
            ll num1 = 999999999, num2 = -1000000000;
            for (int i = 1; i <= max(n, m); i++) {
                if (i % 2 == 1) cout << num1 << " ";
                else cout << num2 << " ";
            }
        }
        else {
            ll num1 = -999999999, num2 = 1000000000;
            for (int i = 1; i <= max(n, m); i++) {
                if (i % 2 == 1) cout << num1 << " ";
                else cout << num2 << " ";
            }
        }
        cout << '\n';
    }
}

void cs() {
    int tstc = 1;
    cin >> tstc;
    while (tstc--) {
        slv();
    }
}

void precalc() {
    return;
}

int main() {
    fastio();
    precalc();
    //precision(1);
    cs();
    return 0;
}

Compilation message

sequence.cpp:25: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
   25 | #pragma warning(disable : 4996)
      | 
sequence.cpp:26: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
   26 | #pragma warning(disable : 6031)
      | 
sequence.cpp: In function 'll range_sum(ll, ll)':
sequence.cpp:95:21: warning: unused variable 'cnt' [-Wunused-variable]
   95 |     ll dif = a - 1, cnt = b - a + 1;
      |                     ^~~
sequence.cpp: In function 'll bin_to_dec(std::string)':
sequence.cpp:118:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |     for (int i = 0; i < s.size(); i++) {
      |                     ~~^~~~~~~~~~
sequence.cpp: In function 'void slv()':
sequence.cpp:202:12: warning: unused variable 'mx' [-Wunused-variable]
  202 |         ll mx = 999999999;
      |            ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 344 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 1 ms 344 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 500 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 344 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 5 ms 860 KB Ok
8 Correct 3 ms 604 KB Ok
9 Correct 6 ms 1116 KB Ok
10 Correct 4 ms 604 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Incorrect 1 ms 348 KB Jury has the better answer : jans = 9, pans = 2
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 344 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 1 ms 344 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 500 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 0 ms 348 KB Ok
13 Correct 1 ms 348 KB Ok
14 Correct 0 ms 348 KB Ok
15 Correct 1 ms 348 KB Ok
16 Incorrect 1 ms 348 KB Jury has the better answer : jans = 9, pans = 2
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 344 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 1 ms 344 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 500 KB Ok
11 Correct 1 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 Correct 0 ms 348 KB Ok
16 Correct 0 ms 348 KB Ok
17 Correct 0 ms 344 KB Ok
18 Correct 1 ms 348 KB Ok
19 Correct 5 ms 860 KB Ok
20 Correct 3 ms 604 KB Ok
21 Correct 6 ms 1116 KB Ok
22 Correct 4 ms 604 KB Ok
23 Correct 1 ms 348 KB Ok
24 Correct 0 ms 348 KB Ok
25 Correct 1 ms 348 KB Ok
26 Incorrect 1 ms 348 KB Jury has the better answer : jans = 9, pans = 2
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 344 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 1 ms 344 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 500 KB Ok
11 Correct 1 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 Correct 0 ms 348 KB Ok
16 Correct 0 ms 348 KB Ok
17 Correct 0 ms 344 KB Ok
18 Correct 1 ms 348 KB Ok
19 Correct 5 ms 860 KB Ok
20 Correct 3 ms 604 KB Ok
21 Correct 6 ms 1116 KB Ok
22 Correct 4 ms 604 KB Ok
23 Correct 1 ms 348 KB Ok
24 Correct 0 ms 348 KB Ok
25 Correct 1 ms 348 KB Ok
26 Incorrect 1 ms 348 KB Jury has the better answer : jans = 9, pans = 2
27 Halted 0 ms 0 KB -