답안 #805387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805387 2023-08-03T16:13:00 Z aymanrs 최후의 만찬 (IOI12_supper) C++14
0 / 100
109 ms 10612 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "advisor.h"
using namespace std;
using namespace __gnu_pbds;
using Set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
void ComputeAdvice(int *C, int N, int K, int M) {
  set<pair<int, int>> q;
  int s[N], nx[N];
  bool f[N] = {false};
  fill(s, s+N, N);
  int c[N];
  for(int i = N-1;i >= 0;i--) {
    nx[i] = s[C[i]];
    s[C[i]] = i;
  }
  int sz = 0;
  Set pbd;
  for(int i = 0;i < K;i++){
    WriteAdvice(s[i] != N);
    if(s[i] != N) {
      sz++;
      pbd.insert(i);
    }
    q.insert({s[i], i});
    f[i] = true;
    c[i] = i;
  }
  for(int i = 0;i < N;i++){
    if(f[C[i]]) {
      int ind = q.begin()->second;
      q.erase(q.begin());
      q.insert({nx[i], ind});
      WriteAdvice(nx[i] != N);
      if(nx[i] == N) sz--;
      else pbd.erase(pbd.find(ind));
      continue;
    }
    int ind = q.rbegin()->second;
    if(q.rbegin()->first == N){
      q.erase(prev(q.end()));
      WriteAdvice(nx[i] != N);
      if(nx[i] != N) {
        sz++;
        pbd.insert(ind);
      }
      q.insert({nx[i], ind});
      continue;
    }
    int L = log2(sz-1) + 1;
    int pind = pbd.order_of_key(ind);
    for(int b = 0;b < L;b++) WriteAdvice(1&(pind>>b));
    WriteAdvice(nx[i] != N);
    if(nx[i] == N) {
      sz--;
      pbd.erase(pbd.find(ind));
    }
    f[c[ind]] = false;
    f[C[i]] = true;
    c[ind] = C[i];
    q.erase(prev(q.end()));
    q.insert({nx[i], ind});
  }
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "assistant.h"
using namespace std;
using namespace __gnu_pbds;
using Set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
void Assist(unsigned char *A, int N, int K, int R) {
  int c[N], indo[N];
  bool f[N] = {false};
  int cur = 0, sz = 0;
  Set pbd;
  vector<pair<int, int>> bad;
  for(int i = 0;i < K;i++){
    f[i] = true;
    c[i] = i;
    indo[i] = i;
    if(A[cur++]){
      sz++;
      pbd.insert(i);
    } else bad.emplace_back(i, i);
  }
  for(int i = 0;i < N;i++){
    int r = GetRequest();
    if(f[r]) {
      if(!A[cur++]){
        sz--;
        pbd.erase(pbd.find(indo[r]));
        bad.emplace_back(r, indo[r]);
      }
      continue;
    }
    if(!bad.empty()){
      PutBack(bad.back().first);
      int ind = bad.back().second;
      f[r] = true;
      f[bad.back().first] = false;
      indo[r] = ind;
      c[ind] = r;
      bad.pop_back();
      if(A[cur++]) {
        sz++;
        pbd.insert(ind);
      } else bad.emplace_back(r, ind);
      continue;
    }
    int pind = 0, L = log2(sz-1);
    for(int b = 0;b < L;b++) {
      if(A[cur]) pind |= 1 << b;
      cur++;
    }
    int ind = *pbd.find_by_order(pind);
    PutBack(c[ind]);
    f[r] = true;
    f[c[ind]] = false;
    c[ind] = r;
    indo[r] = ind;
    if(!A[cur++]){
      sz--;
      pbd.erase(pbd.find(ind));
      bad.emplace_back(r, ind);
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 520 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 8 ms 1408 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 8332 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 952 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 10140 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 109 ms 10216 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 91 ms 10416 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 87 ms 10400 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 90 ms 10352 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 100 ms 10436 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 87 ms 10320 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 85 ms 10260 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 92 ms 10268 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 82 ms 10612 KB Output isn't correct - not an optimal way