답안 #698557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698557 2023-02-13T19:15:04 Z Half 최후의 만찬 (IOI12_supper) C++17
0 / 100
88 ms 12584 KB
#include "advisor.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"WAFFLES "<<i<<"<\n"
#define INF 1000000000000000000LL
#define EPS (0.00000000001L)
#define pi (3.141592653589793L)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}

template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

void ComputeAdvice(int *C, int n, int k, int M) {

  ll bits = 0;
  while((1<<bits) <= k)
    ++bits;
  vector<ll> nxt_ocur(n);
  vector<ll> tmp(n, n);
  vector<vector<ll>> ocur(n);
  for(ll i = n-1; i >= 0; --i){
    nxt_ocur[i] = tmp[C[i]];
    tmp[C[i]] = i;
  }
  for(ll i = 0; i < n; ++i){
    ocur[C[i]].pb(i);
  }
  set<pair<ll,pair<ll, ll>>> sc;
  set<ll> cnt;
  for(ll i = 0; i < k; ++i){
    if(ocur[i].size() != 0)
      sc.insert({-ocur[i][0], {i, i}});
    else
      sc.insert({-n, {i, i}});
    cnt.insert(i);
  }
  vector<ll> adv(n);
  for(ll i = 0; i < n; ++i){
    if(cnt.find(C[i]) != cnt.end()){
      adv[i] = -1;
      continue;
    }
    pair<ll, pair<ll, ll>> rem = *sc.begin();
    sc.erase(sc.begin());
    cnt.erase(rem.ss.ss);
    adv[i] = rem.ss.ff;
    sc.insert({-nxt_ocur[i], {rem.ss.ff, C[i]}});
    cnt.insert(C[i]);
  }

  for(ll advi : adv){
    if(advi == -1){
      for(ll b = 0; b < bits; ++b)
        WriteAdvice(0);
    }else{
      for(ll b = 0; b < bits; ++b)
        WriteAdvice((advi+1) & (1<<b));
    }
  }

}
#include "assistant.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"WAFFLES "<<i<<"<\n"
#define INF 1000000000000000000LL
#define EPS (0.00000000001L)
#define pi (3.141592653589793L)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}

template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

void Assist(unsigned char *A, int N, int K, int R) {

  ll bits = 0;
  while((1<<bits) <= K)
    ++bits;

  vector<ll> sc(N);
  for(ll i = 0; i < K; ++i)
    sc[i] = i;
  for (ll i = 0; i < N; i++) {
    int req = GetRequest();
    ll adv = 0;
    for(ll b = 0; b < bits; ++b){
      adv = adv | (A[bits*i + b]<<b);
    }
    if(adv == 0){
      continue;
    }else{
      adv--;
      PutBack(sc[adv]);
      sc[adv] = req;
    }
  }

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 520 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1592 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 9356 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1040 KB Error - advice must be 0 or 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 11080 KB Error - advice must be 0 or 1
2 Incorrect 68 ms 11332 KB Error - advice must be 0 or 1
3 Incorrect 67 ms 11656 KB Error - advice must be 0 or 1
4 Incorrect 65 ms 11692 KB Error - advice must be 0 or 1
5 Incorrect 65 ms 11624 KB Error - advice must be 0 or 1
6 Incorrect 72 ms 11624 KB Error - advice must be 0 or 1
7 Incorrect 88 ms 11696 KB Error - advice must be 0 or 1
8 Incorrect 63 ms 11592 KB Error - advice must be 0 or 1
9 Incorrect 65 ms 11624 KB Error - advice must be 0 or 1
10 Incorrect 68 ms 12584 KB Error - advice must be 0 or 1