Submission #547166

# Submission time Handle Problem Language Result Execution time Memory
547166 2022-04-09T18:15:41 Z Leo121 Last supper (IOI12_supper) C++14
0 / 100
376 ms 26920 KB
#include <bits/stdc++.h>
#include "advisor.h"
#define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i)
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
    int bits = log2(N);
    forn(i, 0, N - 1){
        forn(j, 0, bits){
            ((C[i] & (1 << j))) ? WriteAdvice(1) : WriteAdvice(0);
        }
    }
}
#include <bits/stdc++.h>
#include "assistant.h"
#define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i)
using namespace std;
const int lim = 1e5;
bool cubeta[lim + 2];
int apu[lim + 2];
struct ura{
    int numero, sigaparicion;
    const bool operator < (const ura & a) const {
        if(sigaparicion == a.sigaparicion){
            return numero < a.numero;
        }
        return sigaparicion < a.sigaparicion;
    }
};
priority_queue<ura> pq;
priority_queue<ura> pqinv;
vector<int> pos[lim + 2];
void Assist(unsigned char *A, int N, int K, int R) {
    forn(i, 0, K - 1){
        cubeta[i] = 1;
    }
    forn(i, 0, N - 1){
        apu[i]= 0;
    }
    int bits = log2(N);
    int numero;
    forn(i, 0, N - 1){
        numero = 0;
        forn(j, 0, bits){
            if(A[(i * (bits + 1)) + j] == 1){
                numero |= (1 << j);
            }
        }
        pos[numero].push_back(i);
    }
    forn(i, 0, K - 1){
        pq.push({i, pos[i][apu[i]]});
        pqinv.push({i, -1 * pos[i][apu[i]]});
    }
    forn(i, 0, N - 1){
        pos[i].push_back(N);
    }
    int sig;
    ura aux;
    forn(i, 0, N - 1){
        sig = GetRequest();
        if(cubeta[sig]){
            continue;
        }
        cubeta[sig] = 1;
        while(!pqinv.empty()){
            aux = pqinv.top();
            if(cubeta[aux.numero]){
                if(-1 * aux.sigaparicion < i){
                    if(pos[aux.numero][apu[aux.numero]] == aux.sigaparicion){
                        apu[aux.numero] ++;
                        if(aux.sigaparicion != N){
                            pq.push({i, pos[aux.numero][apu[aux.numero]]});
                            pq.push({i, -1 * pos[aux.numero][apu[aux.numero]]});
                        }
                    }
                }
            }
            if(-1 * aux.sigaparicion >= i){
                break;
            }
            pqinv.pop();
        }
        aux = pq.top();
        PutBack(aux.numero);
        apu[aux.numero] ++;
        cubeta[aux.numero] = 0;
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 5380 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 7112 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 287 ms 20836 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2940 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 376 ms 24692 KB Execution killed with signal 11
2 Runtime error 356 ms 24748 KB Execution killed with signal 11
3 Runtime error 350 ms 24752 KB Execution killed with signal 11
4 Runtime error 354 ms 24728 KB Execution killed with signal 11
5 Runtime error 339 ms 24648 KB Execution killed with signal 11
6 Runtime error 352 ms 24680 KB Execution killed with signal 11
7 Runtime error 340 ms 24708 KB Execution killed with signal 11
8 Runtime error 364 ms 24708 KB Execution killed with signal 11
9 Runtime error 358 ms 24724 KB Execution killed with signal 11
10 Runtime error 351 ms 26920 KB Execution killed with signal 11