#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 KeepStart[MAX_COULEURS];
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 = nbCouleurs - 1; i >= 0; 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 (i < tailleEchafaud && Last[Couleurs[i]] < 0)
{
KeepStart[Couleurs[i]] = IsIn[Couleurs[i]];
}
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 < tailleEchafaud; i ++)
{
WriteAdvice(KeepStart[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 ++)
{
if (!Advice[i])
ToPush[fin ++] = 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 + tailleEchafaud])
ToPush[fin ++] = id;
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2920 KB |
Output is correct |
2 |
Incorrect |
4 ms |
2920 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
3728 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 |
94 ms |
9072 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 |
6 ms |
3332 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 |
120 ms |
10376 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
124 ms |
10376 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
109 ms |
10328 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
123 ms |
10452 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
107 ms |
10496 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
135 ms |
10444 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
121 ms |
10524 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
125 ms |
10424 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
167 ms |
10360 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
115 ms |
10228 KB |
Output isn't correct - not an optimal way |