답안 #516175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516175 2022-01-20T14:43:18 Z 600Mihnea 최후의 만찬 (IOI12_supper) C++17
0 / 100
136 ms 13536 KB
#include "advisor.h"
#include <bits/stdc++.h>

using namespace std;


void ComputeAdvice(int *a, int n, int k, int ___) {
  vector<int> solution;
  vector<int> when(n);
  int tt = 0;
  vector<vector<int>> nxt(n, vector<int> (1, n + 1));
  for (int i = n - 1; i >= 0; i--) {
    nxt[a[i]].push_back(i);
  }
  set<int> active_guys;
  set<pair<int, int>> nxt_time;
  for (int i = 0; i < k; i++) {
    active_guys.insert(i);
    nxt_time.insert({nxt[i].back(), i});
  }
  for (int i = 0; i < k; i++) {
    when[i] = tt++;
    solution.push_back(0);
  }
  for (int i = 0; i < n; i++) {
    assert((int) nxt_time.size() == k);
    if (!nxt_time.count({nxt[a[i]].back(), a[i]})) {
      auto it = nxt_time.end(); it--;
      int guy = it->second;
      nxt_time.erase(it);
      nxt_time.insert({nxt[a[i]].back(), a[i]});

      when[a[i]] = tt++;
      solution.push_back(0);
    } else {
      solution[when[a[i]]] = 1;
    }
    nxt[a[i]].pop_back();
    assert(nxt_time.count({i, a[i]}));
    nxt_time.erase({i, a[i]});
    nxt_time.insert({i, a[i]});
  }
  assert((int) nxt_time.size() == k);
  for (auto &x : solution) {
    WriteAdvice(x);
  }
  return;
  for (auto &x : solution) {
    cout << x << " ";
  }
  cout << "\n";
  exit(0);
  WriteAdvice(0);
  WriteAdvice(1);
  WriteAdvice(2);

}

#include "assistant.h"
#include <bits/stdc++.h>

using namespace std;


void Assist(unsigned char *a, int n, int k, int r) {
  set<int> act, skip;
  int ptr = 0;
  for (int i = 0; i < k; i++) {
    act.insert(i);
    if (a[ptr++] == 0) {
      skip.insert(i);
    }
  }
  for (int i = 0; i < n; i++) {
    int nxt = GetRequest();
    if (act.count(nxt)) continue;
    assert(!skip.empty());
    int x = *skip.begin();
    skip.erase(x);
    assert(act.count(x));
    act.erase(x);
    act.insert(x);
    assert(ptr < r);
    if (a[ptr++] == 0) {
      skip.insert(i);
    }
    PutBack(x);
  }
  //exit(0);
  return;
/**
  int i;
  set<int> give;
  for (int i = )
  for (i = 0; i < n; i++) {
    int req = GetRequest();
    if (req >= k)
      PutBack(req % k);
  }
**/
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:29:11: warning: unused variable 'guy' [-Wunused-variable]
   29 |       int guy = it->second;
      |           ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 492 KB Output is correct
2 Incorrect 1 ms 492 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1760 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 89 ms 10888 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1168 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 119 ms 12504 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 133 ms 13028 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 131 ms 13536 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 118 ms 13408 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 130 ms 13392 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 126 ms 13468 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 113 ms 13468 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 115 ms 13396 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 128 ms 13316 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 136 ms 13408 KB Error - Putting back a color that is not on the scaffold