Submission #430168

# Submission time Handle Problem Language Result Execution time Memory
430168 2021-06-16T11:51:07 Z JeanBombeur Last supper (IOI12_supper) C++17
34 / 100
502 ms 20356 KB
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include "advisor.h"
using namespace std;

//   <|°_°|>

const int INFINI = (1000 * 1000 * 1000);
const int MAX_COULEURS = (100 * 1000);

int Id[MAX_COULEURS];

int CouleursPresentes[MAX_COULEURS];

vector <int> Dates[MAX_COULEURS];

priority_queue <pair <int, int>> Echafaud;

void ComputeAdvice(int *Couleurs, int nbCouleurs, int tailleEchafaud, int nbBits) {
    
    nbBits ++;
    
    for (int i = 0; i < nbCouleurs; i ++)
    {
        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 ++)
    {
        CouleursPresentes[i] = i;
        Id[i] = i + 1;
        Echafaud.push({Dates[i].back(), i});
    }
    
    int logMax = 0;
    while ((1 << logMax) <= tailleEchafaud)
        logMax ++;
    
    for (int i = 0; i < nbCouleurs; i ++)
    {
        Dates[Couleurs[i]].pop_back();
        int mask = (1 << logMax) - 1;
        if (Id[Couleurs[i]] == 0)
        {
            mask = Echafaud.top().second;
            Id[Couleurs[i]] = mask + 1;
            Id[CouleursPresentes[mask]] = 0;
            CouleursPresentes[mask] = Couleurs[i];
            Echafaud.pop();
        }
        Echafaud.push({Dates[Couleurs[i]].back(), Id[Couleurs[i]] - 1});
        for (int k = 0; k < logMax; k ++)
        {
            WriteAdvice((mask & 1));
            mask >>= 1;
        }
    }
    printf("\n");
    return;
}
#include <iostream>
#include <cstdio>
#include "assistant.h"
using namespace std;

//   <|°_°|>

const int NB_COULEURS = (100 * 1000);

int EchafaudActuel[NB_COULEURS];

void Assist(unsigned char *Advice, int nbCouleurs, int tailleEchafaud, int longueur) {

    longueur ++;

    int logMax = 0;
    while ((1 << logMax) <= tailleEchafaud)
        logMax ++;
        
    for (int i = 0; i < tailleEchafaud; i ++)
    {
        EchafaudActuel[i] = i;
    }
    
    int curBit = 0;
    
    for (int i = 0; i < nbCouleurs; i ++)
    {
        int mask = 0;
        for (int k = curBit + logMax - 1; k >= curBit; k --)
        {
            mask <<= 1;
            mask |= (int)Advice[k];
        }
        curBit += logMax;
        int id = GetRequest();
        if (mask < (1 << logMax) - 1)
        {
            PutBack(EchafaudActuel[mask]);
            EchafaudActuel[mask] = id;
        }
    }
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2924 KB Output is correct
2 Correct 4 ms 2924 KB Output is correct
3 Correct 7 ms 3056 KB Output is correct
4 Correct 9 ms 3196 KB Output is correct
5 Correct 9 ms 3212 KB Output is correct
6 Correct 13 ms 3396 KB Output is correct
7 Correct 17 ms 3676 KB Output is correct
8 Correct 20 ms 3592 KB Output is correct
9 Correct 18 ms 3532 KB Output is correct
10 Correct 20 ms 3664 KB Output is correct
11 Correct 20 ms 3692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 4328 KB Output is correct
2 Correct 180 ms 10588 KB Output is correct
3 Correct 456 ms 20144 KB Output is correct
4 Correct 228 ms 13408 KB Output is correct
5 Correct 362 ms 15880 KB Output is correct
6 Correct 419 ms 17872 KB Output is correct
7 Correct 477 ms 19436 KB Output is correct
8 Correct 364 ms 16820 KB Output is correct
9 Correct 156 ms 12740 KB Output is correct
10 Correct 466 ms 19596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 356 ms 15412 KB Output is correct
2 Correct 480 ms 19560 KB Output is correct
3 Correct 502 ms 19656 KB Output is correct
4 Correct 456 ms 19588 KB Output is correct
5 Correct 424 ms 19828 KB Output is correct
6 Correct 462 ms 19452 KB Output is correct
7 Correct 433 ms 19636 KB Output is correct
8 Correct 414 ms 19272 KB Output is correct
9 Correct 404 ms 20356 KB Output is correct
10 Correct 400 ms 19516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3060 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 436 ms 18168 KB Output is partially correct - 1500000 bits used
2 Correct 392 ms 18360 KB Output is partially correct - 1500000 bits used
3 Correct 439 ms 18408 KB Output is partially correct - 1500000 bits used
4 Correct 394 ms 18332 KB Output is partially correct - 1500000 bits used
5 Correct 409 ms 18304 KB Output is partially correct - 1500000 bits used
6 Correct 401 ms 18468 KB Output is partially correct - 1500000 bits used
7 Correct 437 ms 18428 KB Output is partially correct - 1497585 bits used
8 Correct 421 ms 18496 KB Output is partially correct - 1500000 bits used
9 Correct 409 ms 18372 KB Output is partially correct - 1500000 bits used
10 Correct 418 ms 18132 KB Output is partially correct - 1500000 bits used