Submission #829597

# Submission time Handle Problem Language Result Execution time Memory
829597 2023-08-18T13:12:13 Z MilosMilutinovic Last supper (IOI12_supper) C++14
0 / 100
113 ms 17104 KB
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;

void ComputeAdvice(int *c, int n, int k, int m) {
  vector<int> has(n);
  for (int i = 0; i < k; i++) {
    has[i] = true;
  }
  vector<set<int>> pos(n);
  for (int i = 0; i < n; i++) {
    pos[c[i]].insert(i);
  }
  set<pair<int, int>> st;
  for (int i = 0; i < k; i++) {
    if (pos[i].empty()) {
      st.emplace(n, i);
    } else {
      st.emplace(*pos[i].begin(), i);
    }
  }
  vector<bool> use(n);
  for (int i = 0; i < n; i++) {
    pos[c[i]].erase(pos[c[i]].find(i));
    if (has[c[i]]) {
      use[i] = true;
      continue;
    }
    auto it = prev(st.end());
    int x = it->second;
    st.erase(it);
    has[x] = false;
    has[c[i]] = true;
    if (pos[c[i]].empty()) {
      st.emplace(n, c[i]);
    } else {
      st.emplace(*pos[c[i]].begin(), c[i]);
    }
  }
  vector<vector<int>> p(n);
  for (int i = 0; i < n; i++) {
    p[c[i]].push_back(i);
  }
  for (int i = 0; i < k; i++) {
    if (pos[i].empty() || !use[p[i][0]]) {
      WriteAdvice(0);
    } else {
      WriteAdvice(1);
    }
  }
  vector<int> ptr(n);
  for (int i = 0; i < n; i++) {
    if (ptr[c[i]] == (int) p[c[i]].size() - 1) {
      WriteAdvice(0);
    } else {
      WriteAdvice(use[p[c[i]][ptr[c[i]] + 1]] ? 1 : 0);
    }
    ptr[c[i]] += 1;
  }
}
#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;

void Assist(unsigned char *a, int n, int k, int r) {
  set<int> st;
  for (int i = 0; i < k; i++) {
    if (a[i] == 0) {
      st.insert(i);
    }
  }
  vector<bool> has(n);
  for (int i = 0; i < k; i++) {
    has[i] = true;
  }
  for (int i = 0; i < n; i++) {
    int req = GetRequest();
    if (!has[req]) {
      has[req] = true;
      PutBack(*st.begin());
      has[*st.begin()] = false;
      st.erase(st.begin());
    }
    if (a[i] == 0) {
      st.insert(req);
    }
  }
}

/*
4 2 65000
2 0 3 0

*/
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 508 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 2132 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 13720 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1364 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 16464 KB Output isn't correct - not an optimal way
2 Incorrect 86 ms 16824 KB Output isn't correct - not an optimal way
3 Incorrect 89 ms 16884 KB Output isn't correct - not an optimal way
4 Incorrect 113 ms 17044 KB Output isn't correct - not an optimal way
5 Incorrect 90 ms 17072 KB Output isn't correct - not an optimal way
6 Incorrect 89 ms 16888 KB Output isn't correct - not an optimal way
7 Incorrect 102 ms 16920 KB Output isn't correct - not an optimal way
8 Incorrect 93 ms 17016 KB Output isn't correct - not an optimal way
9 Incorrect 100 ms 17104 KB Output isn't correct - not an optimal way
10 Incorrect 88 ms 15728 KB Output isn't correct - not an optimal way