Submission #958964

# Submission time Handle Problem Language Result Execution time Memory
958964 2024-04-07T10:09:48 Z d4xn Last supper (IOI12_supper) C++17
0 / 100
256 ms 18996 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

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

void ComputeAdvice(int *C, int N, int K, int M) {
  int B = log2(K);

  vector<int> idx[N];
  for (int i = 0; i < N; i++) {
    idx[C[i]].push_back(i);
  }
  for (int i = 0; i < N; i++) {
    idx[i].push_back(N);
    reverse(all(idx[i]));
  }

  int shelf[K];
  set<pair<int, int>> st;
  priority_queue<pair<int, int>> pq;
  for (int i = 0; i < K; i++) {
    shelf[i] = i;
    st.insert(make_pair(i, i)); // (color, posicion)
    pq.push(make_pair(idx[i].back(), i)); // (proxima aparicion, posicion)
    idx[i].pop_back();
  }

  for (int i = 0; i < N; i++) {
    int x = C[i];

    auto it = st.lower_bound(make_pair(x, 0));
    if (it != st.end() && it->first == x) continue;

/*
    while (!pq.empty() && pq.top().first < i) {
      int y = pq.top().second;
      pq.pop();

      pq.push(make_pair(idx[shelf[y]].back(), y));
      idx[shelf[y]].pop_back();
    }
    */

    int y = pq.top().second;
    pq.pop();
    st.erase(make_pair(shelf[y], y));

    for (int j = B; j >= 0; j--) {
      if ((y >> j) & 1) WriteAdvice(1);
      else WriteAdvice(0);
    }
    
    shelf[y] = x;
    st.insert(make_pair(x, y));
    idx[x].pop_back();
    pq.push(make_pair(idx[x].back(), y));
    idx[x].pop_back();
  }
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

void Assist(unsigned char *A, int N, int K, int R) {
  int B = log2(K);

  int shelf[K];
  set<int> st;

  for (int i = 0; i < K; i++) {
    shelf[i] = i;
    st.insert(i);
  }

  int curr = 0;
  for (int i = 0; i < N; i++) {
    int x = GetRequest();
    
    if (st.find(x) != st.end()) continue;

    int y = 0;
    for (int j = B; j >= 0; j--) {
      if (A[curr++] == 1) y ^= (1 << j);
    }

    PutBack(shelf[y]);
    st.erase(shelf[y]);

    shelf[y] = x;
    st.insert(x);
  }

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 780 KB Output is correct
2 Incorrect 2 ms 780 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 2184 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 186 ms 14108 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1068 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 251 ms 17428 KB Output isn't correct - not an optimal way
2 Incorrect 256 ms 17176 KB Output isn't correct - not an optimal way
3 Incorrect 237 ms 17808 KB Output isn't correct - not an optimal way
4 Incorrect 232 ms 17332 KB Output isn't correct - not an optimal way
5 Incorrect 231 ms 17160 KB Output isn't correct - not an optimal way
6 Incorrect 241 ms 17288 KB Output isn't correct - not an optimal way
7 Incorrect 229 ms 17016 KB Output isn't correct - not an optimal way
8 Incorrect 235 ms 17356 KB Output isn't correct - not an optimal way
9 Incorrect 228 ms 17348 KB Output isn't correct - not an optimal way
10 Correct 239 ms 18996 KB Output is partially correct - 1117620 bits used