Submission #440529

# Submission time Handle Problem Language Result Execution time Memory
440529 2021-07-02T11:29:24 Z prvocislo Last supper (IOI12_supper) C++17
100 / 100
199 ms 9756 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

const pair<int, int> nic = {-1, -1};
void ComputeAdvice(int *c, int n, int k, int m) // pole requestov, |c| = pocet farieb, velkost palety, max pocet otazok
{
  vector<int> up(n+k, 0), a(n+k), lst(n, 1e9), nxt(n+k, 1e9);
  for (int i = 0; i < k; i++) a[i] = i;
  for (int i = 0; i < n; i++) a[i+k] = c[i];
  for (int i = n+k-1; i >= 0; i--)
  {
    nxt[i] = lst[a[i]];
    lst[a[i]] = i;
  }
  set<pair<int, int>, greater<pair<int, int> > > s; // {nabuduce, kedy som to tam vlozila}
  vector<pair<int, int> > val(n, nic); // hodnota ktoru tato farba vlozila do setu
  for (int i = 0; i < k; i++) val[i] = {nxt[i], i}, s.insert(val[i]);
  for (int i = k; i < n+k; i++)
  {
    if (val[a[i]].first != -1) // tato farba urcite je na leseni a preto doteraz bola na hornej policke
    {
      s.erase(val[a[i]]);
      up[val[a[i]].second] = true;
    }
    else // nemame ju na leseni, musime nieco vyhodit
    {
      pair<int, int> p = *s.begin();
      s.erase(s.begin());
      val[a[p.second]] = nic; 
    }
    val[a[i]] = {nxt[i], i};
    s.insert(val[a[i]]);
  }
  for (int i = 0; i < n+k; i++) WriteAdvice(up[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

void Assist(unsigned char *a, int n, int k, int r) {
  set<int> up, dw;
  for (int i = 0; i < k; i++) 
  {
    if (a[i]) up.insert(i);
    else dw.insert(i);
  }
  for (int i = k; i < n+k; i++)
  {
    int c = GetRequest();
    if (up.count(c))
    {
      up.erase(c);
    }
    else
    {
      PutBack(*dw.begin());
      dw.erase(dw.begin());
    }
    if (a[i]) up.insert(c);
    else dw.insert(c);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 496 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 2 ms 744 KB Output is correct
4 Correct 3 ms 656 KB Output is correct
5 Correct 3 ms 800 KB Output is correct
6 Correct 7 ms 800 KB Output is correct
7 Correct 6 ms 912 KB Output is correct
8 Correct 5 ms 928 KB Output is correct
9 Correct 6 ms 928 KB Output is correct
10 Correct 8 ms 1024 KB Output is correct
11 Correct 9 ms 940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1364 KB Output is correct
2 Correct 59 ms 3708 KB Output is correct
3 Correct 141 ms 9756 KB Output is correct
4 Correct 83 ms 5880 KB Output is correct
5 Correct 97 ms 5924 KB Output is correct
6 Correct 104 ms 6532 KB Output is correct
7 Correct 136 ms 7928 KB Output is correct
8 Correct 102 ms 7656 KB Output is correct
9 Correct 95 ms 5760 KB Output is correct
10 Correct 161 ms 9176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 6980 KB Output is correct
2 Correct 150 ms 8440 KB Output is correct
3 Correct 159 ms 8516 KB Output is correct
4 Correct 153 ms 8692 KB Output is correct
5 Correct 160 ms 7976 KB Output is correct
6 Correct 163 ms 8684 KB Output is correct
7 Correct 151 ms 8556 KB Output is correct
8 Correct 132 ms 8604 KB Output is correct
9 Correct 158 ms 8560 KB Output is correct
10 Correct 161 ms 8608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 912 KB Output is correct
2 Correct 7 ms 932 KB Output is correct
3 Correct 5 ms 800 KB Output is correct
4 Correct 5 ms 800 KB Output is correct
5 Correct 5 ms 800 KB Output is correct
6 Correct 5 ms 740 KB Output is correct
7 Correct 7 ms 928 KB Output is correct
8 Correct 9 ms 928 KB Output is correct
9 Correct 8 ms 928 KB Output is correct
10 Correct 9 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 8116 KB Output is correct - 120000 bits used
2 Correct 163 ms 8252 KB Output is correct - 122000 bits used
3 Correct 170 ms 8632 KB Output is correct - 125000 bits used
4 Correct 199 ms 8612 KB Output is correct - 125000 bits used
5 Correct 176 ms 8512 KB Output is correct - 125000 bits used
6 Correct 161 ms 8588 KB Output is correct - 125000 bits used
7 Correct 186 ms 8736 KB Output is correct - 124828 bits used
8 Correct 165 ms 8540 KB Output is correct - 124910 bits used
9 Correct 168 ms 8616 KB Output is correct - 125000 bits used
10 Correct 143 ms 8588 KB Output is correct - 125000 bits used