Submission #680748

# Submission time Handle Problem Language Result Execution time Memory
680748 2023-01-11T17:11:02 Z AndreyPavlov Nice sequence (IZhO18_sequence) C++17
0 / 100
8 ms 12068 KB
/* Includes */
#include <bits/stdc++.h>

/* Using libraries */
using namespace std;

/* Defines */
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ld long double
#define pb push_back
#define sz(a) (int)a.size()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define pii pair <int, int>
#define vec pt
#define vc vector
#define all(a) a.begin(), a.end()
#define int long long

const int N = 5e5;
vc <int> g[N], t;
int used[N];

void dfs(int u) {
    used[u] = 1;
    for (int v: g[u]) {
        if (!used[v])
            dfs(v);
    }
    t.pb(u);
}

void solve () {
    int n, m;
    cin >> n >> m;
    int len = n + m - 1 - __gcd(n, m);
    for (int i = 0; i <= len; ++i)
        g[i].clear(), used[i] = 0;
    t.clear();
    for (int i = 0; i <= len; ++i) {
        if (i >= m)
            g[i].pb(i - m);
        if (i >= n)
            g[i - n].pb(i);
    }
    for (int i = 0; i <= len; ++i) {
        if (!used[i])
            dfs(i);
    }
    cout << len << '\n';
    for (int i = 1; i <= len; ++i) {
        cout << t[i] - t[i - 1] << ' ';
    }
    cout << '\n';
}

/* Starting and precalcing */
signed main() {
    fast;
    cout << fixed << setprecision(12);
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Ok
2 Correct 6 ms 11988 KB Ok
3 Incorrect 6 ms 12068 KB there is incorrect sequence
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 11988 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 12048 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 11988 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Ok
2 Correct 6 ms 11988 KB Ok
3 Incorrect 6 ms 12068 KB there is incorrect sequence
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Ok
2 Correct 6 ms 11988 KB Ok
3 Incorrect 6 ms 12068 KB there is incorrect sequence
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Ok
2 Correct 6 ms 11988 KB Ok
3 Incorrect 6 ms 12068 KB there is incorrect sequence
4 Halted 0 ms 0 KB -