Submission #925454

# Submission time Handle Problem Language Result Execution time Memory
925454 2024-02-11T16:35:24 Z anton Last supper (IOI12_supper) C++17
0 / 100
176 ms 18436 KB
#include<bits/stdc++.h>
using namespace std;


#define pii pair<int, int>
#include "advisor.h"

const int INF = 1e9;
void ComputeAdvice(int *C, int N, int K, int M) {

  vector<int> put_down;
  vector<vector<int>> oc;

  int log2 = 1;

  while((1<<log2)<N){
    log2++;
  }

  oc.resize(N);
  for(int i = 0; i<N; i++){
    oc[C[i]].push_back(i);
  }

  set<int> zeros;
  set<int> ones;

  for(int i = 0; i<N; i++){
    oc[i].push_back(INF);
    reverse(oc[i].begin(), oc[i].end());
    if(oc[i].size()==1 || (oc[i].size()==2 && i>=K)){
      zeros.insert(i);
    }
  }

  
  
  set<pii> cur_colors;
  for(int i = 0; i<K; i++){
    cur_colors.insert({oc[i].back(), i});
  }




  
  for(int i = 0; i<N; i++){
    
    int needed = C[i];
    if(cur_colors.find({oc[C[i]].back(), C[i]}) == cur_colors.end()){
      pii removing = *(--cur_colors.end());
      cur_colors.erase(removing);
      if(zeros.find(removing.second) == zeros.end()){
        put_down.push_back(removing.second);
      }
    }
    else{
      cur_colors.erase({oc[needed].back(), needed});
    }
    oc[needed].pop_back();
    cur_colors.insert({oc[needed].back(), needed});

    
  }

  for(int i = 0; i<N; i++){
    if(zeros.find(i) == zeros.end()){
      WriteAdvice(1);
    }
    else{
      WriteAdvice(0);
    }
  }
  for(auto e: put_down){
    for(int i = 0; i<log2; i++){
      WriteAdvice((e&(1<<i))>>i);
    }
  }

}
#include<bits/stdc++.h>
using namespace std;


#define pii pair<int, int>

#include "assistant.h"

void Assist(unsigned char *A, int N, int K, int R) {
  int log2 = 1;

  while((1<<log2)<N){
    log2++;
  }
  set<int> cur_colors;
  for(int i = 0; i<K; i++){
    cur_colors.insert(i);
  }
  vector<int> put_down;
  set<int> zeros;
  for(int i = 0; i<N; i++){
    int val =A[i];
    if(val == 0){
      zeros.insert(i);
    }

  }
  for(int i =0; i<R; i+=log2){
    int val = 0;
    for(int j = 0; j<log2; j++){
      val += A[j+i] * (1<<j);
    }
    put_down.push_back(val);
  }

  reverse(put_down.begin(), put_down.end());
  set<int> zeros_inside;
  for (int i = 0; i < N; i++) {
    int req = GetRequest();
    if(zeros_inside.size()>0 && cur_colors.find(req) == cur_colors.end()){
      PutBack(*zeros_inside.begin());
      zeros_inside.erase(zeros_inside.begin());
    }
    else if(cur_colors.find(req) == cur_colors.end()){
      PutBack(put_down.back());
      cur_colors.erase(put_down.back());
      put_down.pop_back();
    }
    if(zeros.find(req) != zeros.end()){
      zeros_inside.insert(req);
    }
    else{
      cur_colors.insert(req);
    }
  }

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 780 KB Output is correct
2 Incorrect 1 ms 780 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 2492 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 121 ms 14328 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1292 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 17900 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 165 ms 17712 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 156 ms 18100 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 153 ms 17960 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 146 ms 18188 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 154 ms 18196 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 172 ms 18436 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 151 ms 18016 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 176 ms 17916 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 114 ms 17680 KB Error - Putting back a color that is not on the scaffold