Submission #271961

# Submission time Handle Problem Language Result Execution time Memory
271961 2020-08-18T08:09:07 Z 임성재(#5104) Last supper (IOI12_supper) C++14
34 / 100
587 ms 152304 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));

      ans.eb(0);
    }
    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 b = 0;
    for(int j=0; j<mx; j++) {
      if(A[i*mx + j]) b |= (1<<j);
    }

    int x = GetRequest();
    if(b) {
      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;
      |             ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 50 ms 135408 KB Output is correct
2 Correct 48 ms 135416 KB Output is correct
3 Correct 52 ms 135408 KB Output is correct
4 Correct 53 ms 135408 KB Output is correct
5 Correct 55 ms 135664 KB Output is correct
6 Correct 62 ms 135664 KB Output is correct
7 Correct 63 ms 135920 KB Output is correct
8 Correct 69 ms 135920 KB Output is correct
9 Correct 69 ms 136176 KB Output is correct
10 Correct 70 ms 136176 KB Output is correct
11 Correct 76 ms 135928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 136696 KB Output is correct
2 Correct 261 ms 141296 KB Output is correct
3 Correct 546 ms 152304 KB Output is correct
4 Correct 323 ms 142824 KB Output is correct
5 Correct 414 ms 145128 KB Output is correct
6 Correct 492 ms 147424 KB Output is correct
7 Correct 587 ms 149904 KB Output is correct
8 Correct 451 ms 148704 KB Output is correct
9 Correct 245 ms 141288 KB Output is correct
10 Correct 512 ms 150752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 450 ms 147424 KB Output is correct
2 Correct 520 ms 150504 KB Output is correct
3 Correct 514 ms 150488 KB Output is correct
4 Correct 520 ms 150248 KB Output is correct
5 Correct 498 ms 149896 KB Output is correct
6 Correct 554 ms 150496 KB Output is correct
7 Correct 514 ms 150488 KB Output is correct
8 Correct 510 ms 150496 KB Output is correct
9 Correct 469 ms 150496 KB Output is correct
10 Correct 508 ms 150760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 135472 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 499 ms 150240 KB Output is partially correct - 1500000 bits used
2 Correct 504 ms 150240 KB Output is partially correct - 1500000 bits used
3 Correct 529 ms 150496 KB Output is partially correct - 1500000 bits used
4 Correct 513 ms 150496 KB Output is partially correct - 1500000 bits used
5 Correct 498 ms 150752 KB Output is partially correct - 1500000 bits used
6 Correct 522 ms 150840 KB Output is partially correct - 1500000 bits used
7 Correct 530 ms 150240 KB Output is partially correct - 1497585 bits used
8 Correct 550 ms 150496 KB Output is partially correct - 1500000 bits used
9 Correct 511 ms 150496 KB Output is partially correct - 1500000 bits used
10 Correct 568 ms 150752 KB Output is partially correct - 1500000 bits used