Submission #126853

# Submission time Handle Problem Language Result Execution time Memory
126853 2019-07-08T14:14:32 Z RockyB Last supper (IOI12_supper) C++17
0 / 100
391 ms 38392 KB
#include "advisor.h"
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back

#define sz(x) (int)x.size()

#define rep(z, a, b) for (int z = (a); (z) <= (b); z++)
#define per(z, a, b) for (int z = (a); (z) >= (b); z--)

using namespace std;

const int MAXN = (int)2e5 + 7;


vector <int> nxt[MAXN];
int del_val[MAXN];
bool good[MAXN];
void ComputeAdvice(int *C, int N, int K, int M) {
  per(i, N - 1, 0) nxt[i].pb(N);
  per(i, N - 1, 0) nxt[C[i]].pb(i);

  set < pair <int, int > > st;
  rep(i, 0, K - 1) st.insert({nxt[i].back(), i});

  rep(i, 0, N - 1) {
    while (sz(st) && st.begin() -> f <= i) {
      int x = st.begin() -> s;
      st.erase(st.begin());
      nxt[x].pp();
      st.insert({nxt[x].back(), x});
    }
    if (st.count({nxt[C[i]].back(), C[i]})) {
      continue;
    }
    int x = st.rbegin() -> s;
    st.erase(--st.end());
    st.insert({nxt[C[i]].back(), C[i]});
    del_val[i] = x;
  } 
  map <int, int> ask, del;
  per(i, N - 1, 0) {
    /// good if ask < del
    if (ask.count(C[i]) && (!del.count(C[i]) || ask[C[i]] < del[C[i]])) {
      good[i] = 1;
    }

    ask[C[i]] = i;
    del[del_val[i]] = i;
  }
  rep(i, 0, K - 1) {
    if (ask.count(i) && (!del.count(i) || ask[i] < del[i])) {
      WriteAdvice(1);
    }
    else WriteAdvice(0);
  }
  rep(i, 0, N - 1) {
    WriteAdvice(good[i]);
  }
}
#include "assistant.h"
#include <bits/stdc++.h>
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
 
#define sz(x) (int)x.size()
 
#define rep(z, a, b) for (int z = (a); (z) <= (b); z++)
#define per(z, a, b) for (int z = (a); (z) >= (b); z--)
 
using namespace std;
 
const int MAXN = (int)2e5 + 7;
 
void Assist(unsigned char *A, int N, int K, int R) {
  set <int> a[2];
  rep(i, 0, K - 1) a[A[i]].insert(i);
  rep(i, K, K + N - 1) {
    int val = GetRequest();
    
    /* rep(j, 0, 1) {
      cerr << j << " -> ";
      for (auto it : a[j]) cerr << it << ' ';
      cerr << endl;
    } */
    
    if (a[0].count(val) || a[1].count(val)) {
      rep(j, 0, 1) a[j].erase(val);
      a[A[i]].insert(val);  
      continue;
    }
    //cerr << " -> " << *a[0].begin() << endl;
    PutBack(*a[0].begin());
    a[0].erase(a[0].begin());
    
    rep(j, 0, 1) a[j].erase(val);
    a[A[i]].insert(val);
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 9976 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 12496 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 273 ms 28400 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 10992 KB Output is correct
2 Incorrect 18 ms 11504 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 344 ms 32848 KB Output isn't correct - not an optimal way
2 Incorrect 335 ms 32872 KB Output isn't correct - not an optimal way
3 Incorrect 350 ms 33008 KB Output isn't correct - not an optimal way
4 Correct 343 ms 33032 KB Output is correct - 125000 bits used
5 Incorrect 379 ms 33208 KB Output isn't correct - not an optimal way
6 Correct 326 ms 33120 KB Output is correct - 125000 bits used
7 Incorrect 391 ms 32840 KB Output isn't correct - not an optimal way
8 Incorrect 335 ms 33144 KB Output isn't correct - not an optimal way
9 Correct 342 ms 33008 KB Output is correct - 125000 bits used
10 Correct 340 ms 38392 KB Output is correct - 125000 bits used