Submission #1114175

# Submission time Handle Problem Language Result Execution time Memory
1114175 2024-11-18T09:16:26 Z vjudge1 Nice sequence (IZhO18_sequence) C++17
0 / 100
6 ms 27484 KB
//Dost SEFEROĞLU
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e18;
const int N = 2e5+50,Q = 2e5+50;
const int LIM = 1e6+1;
vi edges[LIM];
int v[LIM];
int chain[LIM];
struct DAG {
    int nd;
    int mex = 1;
    int dfs(int node) {
        for (auto it : edges[node]) dfs(it);
        return v[node] = mex++;
    }
    void solve() {
        for (int i = 0;i<=nd;i++) if (!v[i]) dfs(i);
    }
};
void solve() { 
    int n,m;
    cin >> n >> m;
    int r = n+m-2*__gcd(n,m);
    DAG D;
    cout << r << endl;
    D.nd = r;
    for (int i = 0;i<=r;i++) edges[i].clear();
    for (int i = 0;i<=r;i++) {
        v[i] = 0;
        if (i >= m) {
            edges[i].push_back(i-m);
        }
        if (i >= n) {
            edges[i-n].push_back(i);
        }
    } 
    D.solve();
    for (int i = 1;i<=r;i++) {
        cout << v[i]-v[i-1] << ' ';
    }
    cout << '\n'; 
}                    
                             
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef Dodi
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    int t = 1;
    cin >> t; 
    while (t --> 0) solve();
}

Compilation message

sequence.cpp:11:29: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+18' to '2147483647' [-Woverflow]
   11 | const int MOD = 1e9+7,inf = 2e18;
      |                             ^~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 27472 KB Ok
2 Incorrect 6 ms 27472 KB Jury has the better answer : jans = 86, pans = 84
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 27472 KB Jury has the better answer : jans = 1, pans = 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 27484 KB Ok
2 Correct 6 ms 27472 KB Ok
3 Incorrect 5 ms 27472 KB Jury has the better answer : jans = 5, pans = 4
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 27472 KB Jury has the better answer : jans = 3, pans = 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 27472 KB Ok
2 Incorrect 6 ms 27472 KB Jury has the better answer : jans = 86, pans = 84
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 27472 KB Ok
2 Incorrect 6 ms 27472 KB Jury has the better answer : jans = 86, pans = 84
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 27472 KB Ok
2 Incorrect 6 ms 27472 KB Jury has the better answer : jans = 86, pans = 84
3 Halted 0 ms 0 KB -