답안 #829589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829589 2023-08-18T13:07:22 Z MilosMilutinovic 최후의 만찬 (IOI12_supper) C++14
0 / 100
98 ms 22952 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 : 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;
  }
  vector<set<int>> pos(n);
  for (int i = 0; i < n; i++) {
    int req = GetRequest();
    if (!has[req]) {
      assert(!st.empty());
      has[req] = true;
      PutBack(*st.begin());
      has[*st.begin()] = 0;
      st.erase(st.begin());
    }
    if (a[i] == 0) {
      st.insert(req);
    }
  }
}

/*
4 2 65000
2 0 3 0

*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2684 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 18424 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1464 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 22388 KB Output isn't correct - not an optimal way
2 Incorrect 91 ms 22952 KB Output isn't correct - not an optimal way
3 Incorrect 94 ms 22856 KB Output isn't correct - not an optimal way
4 Incorrect 98 ms 22940 KB Output isn't correct - not an optimal way
5 Incorrect 93 ms 22940 KB Output isn't correct - not an optimal way
6 Incorrect 92 ms 22916 KB Output isn't correct - not an optimal way
7 Incorrect 90 ms 22836 KB Output isn't correct - not an optimal way
8 Incorrect 89 ms 22788 KB Output isn't correct - not an optimal way
9 Incorrect 89 ms 22760 KB Output isn't correct - not an optimal way
10 Incorrect 84 ms 21576 KB Output isn't correct - not an optimal way