QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133315#4269. Rainy MarketsHunterXD#0 1ms3576kbC++141.3kb2023-08-01 23:31:582024-07-04 01:08:28

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:08:28]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3576kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-01 23:31:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef int ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define all(x) x.begin(), x.end()

const char nd = '\n';

ll n, k, q;
vl a;

bool check(ll l, ll r) {
  vvl graph(k + 1, vl());
  vl counter(k + 1, 0);

  bool step = true;
  for (ll i = l + 1; i <= r; i++) {
    if (step) {
      graph[a[i]].push_back(a[i - 1]);
      counter[a[i - 1]]++;
    } else {
      graph[a[i - 1]].push_back(a[i]);
      counter[a[i]]++;
    }

    step = !step;
  }

  queue<ll> release;
  for (ll i = 1; i <= k; i++) {
    if (!counter[i]) release.push(i);
  }

  ll temp, res = 0;
  while (!release.empty()) {
    temp = release.front(), release.pop();
    res++;

    for (auto v : graph[temp]) {
      counter[v]--;
      if (!counter[v]) release.push(v);
    }
  }

  return (res == k);
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //
  cin >> n >> k >> q;
  a.resize(n);

  for (auto &v : a) cin >> v;

  vl best(n, 0);
  for (ll i = 0; i < n; i++) best[i] = i;

  ll l, r;
  for (l = 0; l < n; l++) {
    r = max(r, l);
    while ((r + 1 < n) && check(l, r + 1)) r++;
    best[l] = r;
  }

  while (q--) {
    cin >> l >> r;
    l--, r--;

    cout << (check(l, r) ? "YES" : "NO") << nd;
  }
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3576kb

input:

3
10 15 10
20 20
0 0

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

wrong answer read 'YES' but expected 'NO'

Subtask #2:

score: 0
Runtime Error

Test #36:

score: 0
Runtime Error

input:

3
10 15 10
20 20
0 11

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%