이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
#include <bitset>
#include <chrono> 
#include "plants.h"
using namespace std;
 
typedef long long ll;
int n;
using bs = bitset <5000>;
vector <bs> g;
void init(int k, vector <int> r) {
  n = r.size();
  vector <int> p(n);
  for (int x = n - 1; x >= 0; --x) {
    for (int i = 0; i < n; ++i) {
      if (r[i] == 0) {
        p[i] = x;
        r[i] = -1;
        for (int j = 1; j < k; ++j) {
          --r[(i - j + n) % n];
        }
        break;
      }
    }
  }
  //for (int i = 0; i < n; ++i) cout << p[i] + 1 << ' ';
  //cout << endl;
  g.resize(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j < k; ++j) {
      int ij = (i + j) % n;
      if (p[i] > p[ij]) {
        g[i][ij] = 1;
      } else {
        g[ij][i] = 1;
      }
    }
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      if (g[i][k]) g[i] |= g[k];
    }
  }
}
int compare_plants(int x, int y) {
  if (g[x][y]) return 1;
  else if (g[y][x]) return -1;
  else return 0;
}
#ifdef LOCAL
static int nn, k, q;
static std::vector<int> r;
static std:: vector<int> x;
static std:: vector<int> y;
static std:: vector<int> answer;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  cin >> nn >> k >> q;
	r.resize(nn);
	answer.resize(q);
	for (int i = 0; i < nn; i++) {
		int value;
    cin >> value;
		r[i] = value;
	}
	x.resize(q);
	y.resize(q);
	for (int i = 0; i < q; i++) {
    cin >> x[i] >> y[i];
	}
	init(k, r);
	for (int i = 0; i < q; i++) {
		answer[i] = compare_plants(x[i], y[i]);
	}
	for (int i = 0; i < q; i++) {
	  cout << answer[i] << '\n';
	}
}
#endif
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |