답안 #829608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829608 2023-08-18T13:19:32 Z MilosMilutinovic 최후의 만찬 (IOI12_supper) C++14
0 / 100
119 ms 17904 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 (p[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[k + i] == 0) {
      st.insert(req);
    }
  }
}

/*
4 2 65000
2 0 3 0

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 2288 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 14396 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1344 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 17232 KB Output isn't correct - not an optimal way
2 Incorrect 88 ms 17440 KB Output isn't correct - not an optimal way
3 Incorrect 96 ms 17904 KB Output isn't correct - not an optimal way
4 Incorrect 91 ms 17668 KB Output isn't correct - not an optimal way
5 Incorrect 88 ms 17696 KB Output isn't correct - not an optimal way
6 Incorrect 119 ms 17716 KB Output isn't correct - not an optimal way
7 Incorrect 93 ms 17616 KB Output isn't correct - not an optimal way
8 Incorrect 87 ms 17744 KB Output isn't correct - not an optimal way
9 Incorrect 89 ms 17632 KB Output isn't correct - not an optimal way
10 Correct 77 ms 16428 KB Output is correct - 125000 bits used