#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){
if(pos[aux.numero][apu[aux.numero]] <= i){
apu[aux.numero] ++;
pq.push({i, pos[aux.numero][apu[aux.numero]]});
pqinv.push({i, -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]]});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2948 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2940 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
4488 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
308 ms |
16512 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2940 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
422 ms |
19976 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
393 ms |
19724 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
385 ms |
19836 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
411 ms |
19944 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
393 ms |
19816 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
418 ms |
19736 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
412 ms |
19808 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
394 ms |
19932 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
398 ms |
19908 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
437 ms |
20212 KB |
Output isn't correct - not an optimal way |