#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 = 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 (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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2976 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2924 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
3772 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
89 ms |
8932 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
3336 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
121 ms |
10340 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
115 ms |
10300 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
112 ms |
10544 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
128 ms |
10424 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
126 ms |
10436 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
117 ms |
10408 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
124 ms |
10492 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
111 ms |
10460 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
127 ms |
10604 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
119 ms |
10232 KB |
Output isn't correct - not an optimal way |