#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include "advisor.h"
using namespace std;
// <|°_°|>
const int INFINI = (1000 * 1000 * 1000);
const int MAX_COULEURS = (100 * 1000);
vector <int> Dates[MAX_COULEURS];
int Last[MAX_COULEURS];
bool IsIn[MAX_COULEURS];
priority_queue <pair <int, int>> APush;
bool Keep[MAX_COULEURS];
void ComputeAdvice(int *Couleurs, int nbCouleurs, int tailleEchafaud, int nbBits) {
nbBits ++;
for (int i = 0; i < nbCouleurs; i ++)
{
Last[i] = -1;
Dates[i].push_back(INFINI);
}
for (int i = 0; i < nbCouleurs; i ++)
{
Dates[Couleurs[i]].push_back(i);
}
for (int i = 0; i < tailleEchafaud; i ++)
{
IsIn[i] = true;
APush.push({Dates[i].back(), i});
}
for (int i = 0; i < nbCouleurs; i ++)
{
Dates[Couleurs[i]].pop_back();
if (Last[Couleurs[i]] >= 0)
{
Keep[Last[Couleurs[i]]] = IsIn[Couleurs[i]];
}
Last[Couleurs[i]] = i;
if (!IsIn[Couleurs[i]])
{
int id = APush.top().second;
APush.pop();
IsIn[id] = false;
IsIn[Couleurs[i]] = true;
}
APush.push({Dates[Couleurs[i]].back(), Couleurs[i]});
}
for (int i = 0; i < nbCouleurs; i ++)
{
WriteAdvice(Keep[i]);
}
return;
}
#include <iostream>
#include <cstdio>
#include "assistant.h"
using namespace std;
// <|°_°|>
const int NB_COULEURS = (100 * 1000);
bool IsOn[NB_COULEURS];
int ToPush[NB_COULEURS];
int fin = 0;
void Assist(unsigned char *Advice, int nbCouleurs, int tailleEchafaud, int nbBits) {
nbBits ++;
for (int i = 0; i < tailleEchafaud; i ++)
{
IsOn[i] = true;
}
for (int i = 0; i < nbCouleurs; i ++)
{
int id = GetRequest();
if (!IsOn[id])
{
IsOn[id] = true;
IsOn[ToPush[-- fin]] = false;
PutBack(ToPush[fin]);
}
if (!Advice[i])
ToPush[fin ++] = id;
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2924 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
3680 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
8684 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
3328 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
113 ms |
10024 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
109 ms |
10004 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
117 ms |
10032 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
99 ms |
10080 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
135 ms |
10044 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
110 ms |
10096 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
107 ms |
10092 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
137 ms |
10100 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
110 ms |
10072 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
111 ms |
9636 KB |
Error - Putting back a color that is not on the scaffold |