Submission #26618694


Source Code Expand

// {{{
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define debug(x...)
#define debug_arr(x...)
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// }}}

// 10 / 5 - 7 /2 - 9 / 8
// (10 * 7 / (5 * 2)  -   9 / 8
//
// 10 8 9 7
// 10 * 8 / (9 / 7)
//
// a / b ---   c  / d

// a * c / (b / d)
// a / d ---- c / b  ----- c / b > 1 b < c

//  1 2 3 4 5 6 4 2 3 1
//  6 /2  * 3 /  1
//  6 /1

const int N = 2e5 + 10;
int n;
int a[N];
bool v[N];
int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    while (cin >> n)
    {
        clr(v, 0);
        for (int i = 1; i <= n; ++i) cin >> a[i];

        int st = 1;
        while (1)
        {
            if (st > n) break;

            int bg = st;
            while (bg + 1 <= n && a[bg + 1] >= a[bg]) bg++;
            if (bg == n) break;

            int ed = bg + 1;
            assert(a[ed] < a[bg]);
            while (ed + 1 <= n && a[ed + 1] <= a[ed]) ed++;

            v[bg] = v[ed] = 1;

            st = ed + 1;
            if (st > n) break;
        }
        for (int i = 1; i <= n; i++)
        {
            cout << v[i] << " ";
        }
        cout << '\n';
    }

    return 0;
}

Submission Info

Submission Time
Task A - Gold and Silver
User mickeyandkaka
Language C++ (GCC 9.2.1)
Score 400
Code Size 1555 Byte
Status AC
Exec Time 42 ms
Memory 4568 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 18
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 7 ms 3680 KiB
00-sample-002.txt AC 2 ms 3816 KiB
00-sample-003.txt AC 2 ms 3676 KiB
01-001.txt AC 2 ms 3680 KiB
01-002.txt AC 5 ms 3656 KiB
01-003.txt AC 18 ms 4108 KiB
01-004.txt AC 38 ms 4568 KiB
01-005.txt AC 21 ms 4128 KiB
01-006.txt AC 38 ms 4368 KiB
01-007.txt AC 41 ms 4500 KiB
01-008.txt AC 40 ms 4420 KiB
01-009.txt AC 42 ms 4552 KiB
01-010.txt AC 38 ms 4408 KiB
01-011.txt AC 39 ms 4536 KiB
01-012.txt AC 40 ms 4428 KiB
01-013.txt AC 37 ms 4428 KiB
01-014.txt AC 40 ms 4412 KiB
01-015.txt AC 40 ms 4464 KiB