Submission #38107

# Submission time Handle Problem Language Result Execution time Memory
38107 2018-01-01T07:07:41 Z funcsr Last supper (IOI12_supper) C++14
0 / 100
442 ms 148056 KB
#include "advisor.h"
#include <iostream>
#include <vector>
#include <set>
#include <cassert>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(xs) xs.begin(), xs.end()
#define pb push_back
#define _1 first
#define _2 second
#define INF 1145141919
#define MOD 1000000000
using namespace std;
typedef pair<int, int> P;

int OK[100000];
queue<int> G[100000];

inline int next(int c) {
  if (G[c].empty()) return INF;
  return G[c].front();
}

void ComputeAdvice(int *C, int N, int K, int M) {
  rep(i, N) OK[i] = -1;
  rep(i, N) G[C[i]].push(i);
  priority_queue<P> pq;
  rep(i, K) {
    pq.push(P(next(C[i]), C[i]));
    OK[i] = i;
  }
  vector<int> seq;
  rep(i, N) {
    int c = C[i];
    G[c].pop();
    if (OK[c] != -1) {
      seq.pb(0);
    }
    else {
      while (pq.top()._1 < i) {
        int s = pq.top()._2;
        pq.pop();
        pq.push(P(next(s), s));
      }
      int w = pq.top()._2;
      int pos = OK[w];
      OK[w] = -1;
      pq.pop();
      pq.push(P(next(c), c));
      OK[c] = pos;
      seq.pb(pos+1);
    }
  }
  int per = 1, k = 1;
  for (int k=0; k<20; k++) if ((K>>k)&1) per = max(per, k+1);
  //cout<<"{";for (int x : seq)cout<<x<<",";cout<<"}\n";
  //cout<<"per="<<per<<"\n";
  for (int x : seq) {
    rep(i, per) {
      WriteAdvice((x>>i)&1);
    }
  }
}
#include "assistant.h"
#include <iostream>
#include <vector>
#include <set>
#include <cassert>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(xs) xs.begin(), xs.end()
#define pb push_back
#define _1 first
#define _2 second
#define INF 1145141919
#define MOD 1000000000
using namespace std;
typedef pair<int, int> P;

int _OK[100000];
int slot[100000];

void Assist(unsigned char *A, int N, int K, int R) {
  int per = 1, k = 1;
  for (int k=0; k<20; k++) if ((K>>k)&1) per = max(per, k+1);
  vector<int> seq;
  //cout<<"per="<<per<<"\n";
  int head = 0;
  rep(_, R/per) {
    int s = 0;
    rep(i, per) {
      int bit = A[head++];
      s |= bit<<i;
    }
    seq.pb(s);
  }
  //cout<<"{";for (int x : seq)cout<<x<<",";cout<<"}\n";

  rep(i, N) _OK[i] = -1;
  rep(i, K) _OK[i] = i, slot[i] = i;
  rep(i, N) {
    int c = GetRequest();
    if (_OK[c] != -1) continue;
    int back = slot[seq[i]-1];
    PutBack(back);
    _OK[back] = -1;
    _OK[c] = back;
    slot[seq[i]-1] = c;
  }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:57:16: warning: unused variable 'k' [-Wunused-variable]
   int per = 1, k = 1;
                ^

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:23:16: warning: unused variable 'k' [-Wunused-variable]
   int per = 1, k = 1;
                ^
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 135408 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 136680 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 341 ms 145360 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 145360 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 437 ms 147544 KB Output isn't correct - not an optimal way
2 Incorrect 420 ms 148056 KB Output isn't correct - not an optimal way
3 Incorrect 421 ms 148056 KB Output isn't correct - not an optimal way
4 Incorrect 419 ms 148056 KB Output isn't correct - not an optimal way
5 Incorrect 442 ms 148056 KB Output isn't correct - not an optimal way
6 Incorrect 431 ms 148056 KB Output isn't correct - not an optimal way
7 Incorrect 414 ms 148056 KB Output isn't correct - not an optimal way
8 Incorrect 410 ms 148056 KB Output isn't correct - not an optimal way
9 Incorrect 425 ms 148056 KB Output isn't correct - not an optimal way
10 Incorrect 414 ms 148056 KB Output isn't correct - not an optimal way