답안 #271970

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
271970 2020-08-18T08:11:54 Z 임성재(#5104) 최후의 만찬 (IOI12_supper) C++14
0 / 100
440 ms 148608 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

static queue<int> q[100010];
static set<pii> s;
static vector<int> ans;
static int mx;
static int tree[100010];

static void update(int i, int x) {
  i++;
  while(i <= 100000) {
    tree[i] += x;
    i += i & -i;
  }
}

static int sum(int i) {
  i++;
  int ret = 0;
  while(i) {
    ret += tree[i];

    i -= i & -i;
  }

  return ret;
}


void ComputeAdvice(int *C, int N, int K, int M) {
  while(K >> mx) mx++;

  for(int i=0; i<N; i++) {
    q[C[i]].em(i);
  }

  for(int i=0; i<N; i++)
    q[i].em(N);

  for(int i=0; i<K; i++) {
    s.insert(mp(q[i].front(), i));
    update(i, 1);
  }

  for(int i=0; i<N; i++) {
    if(s.begin()->fi == i) {
      int x = s.begin()->se;
      q[x].pop();

      s.erase(s.begin());
      s.insert(mp(q[x].front(), x));
    }
    else {
      int x = prev(s.end())->se;
      s.erase(prev(s.end()));

      q[C[i]].pop();
      s.insert(mp(q[C[i]].front(), C[i]));

      ans.eb(sum(x));

      update(x, -1);
      update(C[i], 1);
    }
  }

  for(auto i : ans) {
    for(int j=0; j<mx; j++) {
      if(i & (1<<j)) WriteAdvice(1);
      else WriteAdvice(0);
    }
  }
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

static int mx, n;
static int tree[100010];

static void update(int i, int x) {
  i++;
  while(i <= 100000) {
    tree[i] += x;
    i += i & -i;
  }
}

static int sum(int i) {
  i++;
  int ret = 0;
  while(i) {
    ret += tree[i];

    i -= i & -i;
  }

  return ret;
}

static int Find(int x) {
  int l = 0, r = 100000 - 1;

  while(l != r) {
    int m = l + r >> 1;
    if(sum(m) >= x) r = m;
    else l = m+1;
  }

  return l;
}

void Assist(unsigned char *A, int N, int K, int R) {
  while(K >> mx) mx++;
  n = N;

  for(int i=0; i<K; i++)
    update(i, 1);

  for(int i=0; i<N; i++) {
    int x = GetRequest();

    if(sum(x) - sum(x-1)) continue;
    
    int b = 0;
    for(int j=0; j<mx; j++) {
      if(A[i*mx + j]) b |= (1<<j);
    }

    int y = Find(b);
    update(x, 1);
    update(y, -1);
    PutBack(y);
  }
}

Compilation message

assistant.cpp: In function 'int Find(int)':
assistant.cpp:46:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |     int m = l + r >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 135424 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 76 ms 136176 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 297 ms 143592 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 135424 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 374 ms 145472 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 439 ms 145256 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 360 ms 145384 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 342 ms 145384 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 341 ms 145384 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 362 ms 145384 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 352 ms 145384 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 340 ms 145640 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 336 ms 145384 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 440 ms 148608 KB Error - Putting back a color that is not on the scaffold