Submission #547185

# Submission time Handle Problem Language Result Execution time Memory
547185 2022-04-09T18:52:02 Z Leo121 Last supper (IOI12_supper) C++14
20 / 100
432 ms 20744 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, K, N - 1){
        cubeta[i] = 0;
    }
    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, N - 1){
        pos[i].push_back(N);
    }
    forn(i, 0, K - 1){
        pq.push({i, pos[i][apu[i]]});
        pqinv.push({i, -1 * pos[i][apu[i]]});
    }
    int sig;
    ura aux;
    forn(i, 0, N - 1){
        sig = GetRequest();
        if(cubeta[sig]){
            continue;
        }
        while(!pqinv.empty()){
            aux = pqinv.top();
            if(cubeta[aux.numero]){
                if(-1 * aux.sigaparicion < i){
                    while(pos[aux.numero][apu[aux.numero]] <= i){
                        apu[aux.numero] ++;
                    }
                    pq.push({aux.numero, pos[aux.numero][apu[aux.numero]]});
                    pqinv.push({aux.numero, -1 * pos[aux.numero][apu[aux.numero]]});
                    pqinv.pop();
                }
                else{
                    break;
                }
            }
            else{
                pqinv.pop();
            }

        }
        cubeta[sig] = 1;
        while(!pq.empty()){
            aux = pq.top();
            if(!cubeta[aux.numero]){
                pq.pop();
            }
            else{
                break;
            }
        }
        ///cout << aux.sigaparicion << "\n";
        PutBack(aux.numero);
        while(pos[aux.numero][apu[aux.numero]] <= i){
            apu[aux.numero] ++;
        }
        cubeta[aux.numero] = 0;
        pq.pop();
        while(pos[sig][apu[sig]] <= i){
            apu[sig] ++;
        }
        pq.push({sig, pos[sig][apu[sig]]});
        pqinv.push({sig, -1 * pos[sig][apu[sig]]});
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2944 KB Output is correct
2 Correct 3 ms 2948 KB Output is correct
3 Correct 5 ms 3088 KB Output is correct
4 Correct 10 ms 3288 KB Output is correct
5 Correct 17 ms 3596 KB Output is correct
6 Correct 19 ms 3612 KB Output is correct
7 Correct 15 ms 3616 KB Output is correct
8 Correct 17 ms 3708 KB Output is correct
9 Correct 16 ms 3592 KB Output is correct
10 Correct 17 ms 3732 KB Output is correct
11 Correct 17 ms 3736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 4476 KB Output is correct
2 Correct 189 ms 11376 KB Output is correct
3 Correct 376 ms 20512 KB Output is correct
4 Correct 386 ms 19444 KB Output is correct
5 Correct 387 ms 19524 KB Output is correct
6 Correct 379 ms 20136 KB Output is correct
7 Correct 401 ms 20540 KB Output is correct
8 Correct 317 ms 17760 KB Output is correct
9 Correct 362 ms 19252 KB Output is correct
10 Correct 410 ms 20468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 306 ms 16688 KB Output is correct
2 Incorrect 20 ms 4912 KB Error - advice is too long
3 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 Correct 410 ms 20564 KB Output is partially correct - 1700000 bits used
2 Correct 404 ms 20532 KB Output is partially correct - 1700000 bits used
3 Correct 393 ms 20440 KB Output is partially correct - 1700000 bits used
4 Correct 383 ms 20516 KB Output is partially correct - 1700000 bits used
5 Correct 427 ms 20636 KB Output is partially correct - 1700000 bits used
6 Correct 396 ms 20480 KB Output is partially correct - 1700000 bits used
7 Correct 394 ms 20744 KB Output is partially correct - 1697263 bits used
8 Correct 411 ms 20588 KB Output is partially correct - 1700000 bits used
9 Correct 393 ms 20548 KB Output is partially correct - 1700000 bits used
10 Correct 432 ms 20168 KB Output is partially correct - 1700000 bits used