Submission #1082584

# Submission time Handle Problem Language Result Execution time Memory
1082584 2024-08-31T16:30:26 Z juicy Zagonetka (COI18_zagonetka) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 105;

int n, lab;
bool flg;
int a[N], p[N], memo[N][N], deg[N], res[N], pos[N];
bool e[N][N], vis[N];

bool cmp(int i, int j) {
  if (~memo[i][j]) {
    return memo[i][j];
  }
  if (a[i] >= a[j]) {
    return (memo[i][j] = 0);
  }
  vector<int> ver;
  for (int k = a[i]; k <= a[j]; ++k) {
    ver.push_back(pos[k]);
  }
  for (int u : ver) {
    for (int v : ver) {
      if (u != i || v != j) {
        e[u][v] = cmp(u, v);
      }
    }
  }
  e[j][i] = 1;
  queue<int> q;
  for (int u : ver) {
    deg[u] = 0;
    for (int v : ver) {
      deg[u] += e[v][u];
    }
    if (!deg[u]) {
      q.push(u);
    }
  }
  for (int k = 1; k <= n; ++k) {
    p[k] = a[k];
  }
  int c = a[i];
  while (q.size()) {
    int u = q.front(); q.pop();
    p[u] = c++;
    for (int v : ver) {
      if (e[u][v] && --deg[v] == 0) {
        q.push(v);
      }
    }
  }
  e[j][i] = 0;
  if (c <= a[j]) {
    return 1;
  }
  cout << "query ";
  for (int i = 1; i <= n; ++i) {
    cout << p[i] << " ";
  }
  cout << endl;
  int x; cin >> x;
  return !x;
}

bool hasEdge(int u, int v) {
  return flg ? cmp(v, u) : cmp(u, v);
}

void dfs(int u) {
  vis[u] = 1;
  for (int i = n; i; --i) {
    if (!vis[i] && hasEdge(u, i)) {
      dfs(i);
    } 
  }
  res[u] = lab--;
} 

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  jury::conds = {{2, 1}, {3, 4}};
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  memset(memo, -1, sizeof(memo));
  lab = n;
  for (int i = n; i; --i) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  cout << "end" << endl;
  for (int i = 1; i <= n; ++i) {
    cout << res[i] << " ";
  }
  cout << endl;
  flg = 1;
  lab = n;
  memset(vis, 0, sizeof(vis));
  for (int i = n; i; --i) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << n - res[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}

Compilation message

zagonetka.cpp: In function 'int main()':
zagonetka.cpp:90:3: error: 'jury' has not been declared
   90 |   jury::conds = {{2, 1}, {3, 4}};
      |   ^~~~