Submission #271955

# Submission time Handle Problem Language Result Execution time Memory
271955 2020-08-18T08:06:36 Z 임성재(#5104) Last supper (IOI12_supper) C++14
0 / 100
528 ms 150752 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]));

      update(x, -1);
      update(C[i], 1);
      ans.eb(sum(x));
    }
  }

  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 Incorrect 54 ms 135408 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 136688 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 430 ms 147608 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 135680 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 503 ms 149952 KB Error - Not putting back color when it is not on the scaffold
2 Incorrect 499 ms 150144 KB Error - Not putting back color when it is not on the scaffold
3 Incorrect 485 ms 150496 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 498 ms 150496 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 486 ms 150504 KB Error - Not putting back color when it is not on the scaffold
6 Incorrect 501 ms 150496 KB Error - Not putting back color when it is not on the scaffold
7 Incorrect 498 ms 150496 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 493 ms 150752 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 528 ms 150496 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 525 ms 150752 KB Error - Not putting back color when it is not on the scaffold