#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;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
5372 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
36 ms |
7032 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
304 ms |
20792 KB |
Execution killed with signal 11 |
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 |
Runtime error |
377 ms |
24576 KB |
Execution killed with signal 11 |
2 |
Runtime error |
386 ms |
24776 KB |
Execution killed with signal 11 |
3 |
Runtime error |
355 ms |
24752 KB |
Execution killed with signal 11 |
4 |
Runtime error |
390 ms |
24672 KB |
Execution killed with signal 11 |
5 |
Runtime error |
343 ms |
24804 KB |
Execution killed with signal 11 |
6 |
Runtime error |
370 ms |
24676 KB |
Execution killed with signal 11 |
7 |
Runtime error |
372 ms |
24624 KB |
Execution killed with signal 11 |
8 |
Runtime error |
351 ms |
24836 KB |
Execution killed with signal 11 |
9 |
Runtime error |
346 ms |
24760 KB |
Execution killed with signal 11 |
10 |
Runtime error |
340 ms |
26832 KB |
Execution killed with signal 11 |