結果

問題 No.905 Sorted?
ユーザー batsumarubatsumaru
提出日時 2019-10-11 22:27:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 1,152 bytes
コンパイル時間 2,808 ms
コンパイル使用メモリ 168,164 KB
実行使用メモリ 5,648 KB
最終ジャッジ日時 2023-08-16 18:37:52
合計ジャッジ時間 5,307 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 206 ms
4,380 KB
testcase_09 AC 124 ms
4,380 KB
testcase_10 AC 193 ms
5,096 KB
testcase_11 AC 186 ms
5,008 KB
testcase_12 AC 218 ms
4,696 KB
testcase_13 AC 224 ms
5,496 KB
testcase_14 AC 225 ms
5,348 KB
testcase_15 AC 210 ms
5,364 KB
testcase_16 AC 229 ms
5,648 KB
testcase_17 AC 227 ms
5,408 KB
testcase_18 AC 168 ms
5,344 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  vector<ll> inc(n), dec(n);
  iota(ALL(inc), 0);
  iota(ALL(dec), 0);
  ll i = 1, p = 0;
  while (i <= n) {
    if (i == n || a[i - 1] > a[i]) {
      FOR(j, p, i) { inc[j] = i - 1; }
      p = i;
    }
    i++;
  }
  i = 1, p = 0;
  while (i <= n) {
    if (i == n || a[i - 1] < a[i]) {
      FOR(j, p, i) { dec[j] = i - 1; }
      p = i;
    }
    i++;
  }

  // REP(i, n) {
  //   DUMP(i);
  //   DUMP(inc[i]);
  //   DUMP(dec[i]);
  // }
  ll q;
  cin >> q;
  while (q--) {
    ll l, r;
    cin >> l >> r;
    vector<ll> ans(2, 0);
    if (r <= inc[l]) ans[0] = 1;
    if (r <= dec[l]) ans[1] = 1;
    REP(i, 2) cout << ans[i] << " \n"[i == 1];
  }
}
0