Submission #1138010

#TimeUsernameProblemLanguageResultExecution timeMemory
1138010ConquerConquererpopa (BOI18_popa)C++20
0 / 100
5 ms420 KiB
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;

/*
int num[1005];

bool query(int x, int y, int u, int v) {
    int P = num[x], Q = num[u];
    for (int i = x + 1; i <= y; i++)
        P = __gcd(P, num[i]);

    for (int i = u + 1; i <= v; i++)
        Q = __gcd(Q, num[i]);

    return (P == Q);
}
*/
int solve(int N, int* Left, int* Right) {
    stack<int> st;
    int root = -1;

    for (int i = 0; i < N; i++)
        Left[i] = Right[i] = -1;

    for (int i = 0; i < N; i++) {
        while (st.size() && query(st.top(), i, i, i)) {
            Right[st.top()] = -1;
            Left[i] = st.top();
            st.pop();
        }

        if (st.empty()) root = i;
            else Right[st.top()] = i;
        st.push(i);
    }

    return root;
}

/*
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> num[i];

    int A[n], B[n];
    int root = solve(n, A, B);

    cout << "Root " << root << '\n';
    for (int i = 0; i < n; i++)
        cout << A[i] << ' ';
    cout << '\n';

    for (int i = 0; i < n; i++)
        cout << B[i] << ' ';
    cout << '\n';

    return 0;
}
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...