結果

問題 No.905 Sorted?
ユーザー minamiminami
提出日時 2019-10-11 21:54:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,613 bytes
コンパイル時間 1,665 ms
コンパイル使用メモリ 171,436 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2023-08-16 17:42:11
合計ジャッジ時間 4,347 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 133 ms
5,764 KB
testcase_09 AC 85 ms
4,928 KB
testcase_10 AC 120 ms
6,968 KB
testcase_11 AC 124 ms
5,896 KB
testcase_12 AC 149 ms
5,904 KB
testcase_13 AC 138 ms
7,292 KB
testcase_14 AC 139 ms
7,164 KB
testcase_15 AC 147 ms
7,316 KB
testcase_16 AC 138 ms
5,352 KB
testcase_17 AC 148 ms
7,424 KB
testcase_18 AC 106 ms
7,004 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    int Q;
    cin >> Q;
    vector<int> l(Q), r(Q);
    rep(i, 0, Q) cin >> l[i] >> r[i];

    using P = pair<int, int>;
    vector<P> X, Y;
    X.emplace_back(-2, -1);
    Y.emplace_back(-2, -1);
    int x = 0;
    int y = 0;
    rep(i, 1, N) {
        if (A[i - 1] > A[i]) {
            X.emplace_back(x, i);
            x = i;
        }
        if (A[i - 1] < A[i]) {
            Y.emplace_back(y, i);
            y = i;
        }
    }
    X.emplace_back(x, N);
    Y.emplace_back(y, N);
    dump(X, Y);

    rep(q, 0, Q) {
        auto p = upper_bound(all(X), P(l[q], INF));
        p--;
        dump(*p);
        cout << (p->first <= l[q] && r[q] < p->second) << " ";
        p = upper_bound(all(Y), P(l[q], INF));
        p--;
        cout << (p->first <= l[q] && r[q] < p->second) << endl;
    }

    return 0;
}
0