/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 74ms 17.641 MiB
#2 Wrong Answer 75ms 17.613 MiB
#3 Wrong Answer 74ms 17.648 MiB

Code

/**
 *    author:   Binoy Barman
 *    created:  2025-01-02 21:00:22
**/

#include<bits/stdc++.h>
#ifdef LOCAL
#include "debug/trace.hpp"
#else
#define dbg(...) 42
#define print(...) 42
#endif
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = 1e9;

#define int long long
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Testcase_Handler int tts, tc = 1; cin >> tts; hell: while(tts--)
#define uniq(v) sort(all(v)), v.resize(distance(v.begin(), unique(v.begin(), v.end())))
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {bool first = true;for(auto &x : a) {if(!first) out << ' ';first = false;out << x;}return out;};

namespace Dark_Lord_Binoy {
void preprocess() {}
void setup() {
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
    preprocess();

    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
}

const int N = 1e5 + 9;

vector<int> divisors[N];
void sieve() {
    for (int i = 1; i < N; i++) {
        for (int j = i; j < N; j += i) {
            divisors[j].push_back(i);
        }
    }
}

int32_t main() {
    Dark_Lord_Binoy::setup();

    sieve();
    int n;
    cin >> n;
    vector<int> f(N);
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        dbg(divisors[x]);
        for(auto d : divisors[x]) {
            f[d]++;
        }
    }
    // set<int> s;
    vector<int> val(N), ans(n + 1);
    for (int i = N - 1; i > 0; i--) {
        // if(f[i] != 0 && s.find(f[i]) == s.end()) {
        //     s.insert(f[i]);
        val[f[i]] = max(i, val[f[i]]);
        // }
    }
    int pre = 0;
    // for (int i = N - 1; i > 0; i--) {
    //     if(val[i]) dbg(i, val[i]);
    //     pre = max(pre, val[i]);
    //     if(i <= n) ans[i] = pre;
    // }
    pre = 0;
    for (int i = 1; i <= n; i++) {
        ans[i] = val[i];
        dbg(ans[i], pre);
        cout << (ans[i] != 0 ? ans[i] : pre) << " ";
        pre |= (ans[i] > 0);
    }
    cout << nl;

    print(_Time_);
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1151 Max gcd group
Contest
Happy New Year 2025
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-02 16:23:48
Judged At
2025-01-02 16:23:48
Judged By
Score
0
Total Time
75ms
Peak Memory
17.648 MiB