#include "advisor.h"
#include <iostream>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M){
vector<int>orden(N, 0);
for (int i=0; i<N; i++) orden[C[i]]++;
for (int i=0; i<K; i++){
if (orden[i]==0) WriteAdvice(0);
else WriteAdvice(1);
}
for (int i=0; i<N; i++){
int x=C[i];
orden[x]--;
if (orden[x]==0) WriteAdvice(0);
else WriteAdvice(1);
}return;
}
#include "assistant.h"
#include <iostream>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R){
queue<int>away;
unordered_set<int>current;
for (int i=0; i<K; i++){
current.insert(i);
if (A[i]=='0') away.push(i);
}
for (int i=0; i<N; i++){
int follow=GetRequest();
char x=A[i+K];
if (!(current.find(follow)!=current.end())){
int remov=-1;
if (away.empty()) remov=*current.begin();
else{
remov=away.front();
away.pop();
}
PutBack(remov);
current.erase(remov);
current.insert(follow);
}if (x=='0') away.push(follow);
}return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
784 KB |
Output is correct |
2 |
Incorrect |
0 ms |
788 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1176 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
4684 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1092 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
5400 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
40 ms |
5896 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
48 ms |
5812 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
45 ms |
5976 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
38 ms |
5908 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
40 ms |
5896 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
38 ms |
5912 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
38 ms |
5932 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
38 ms |
5884 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
39 ms |
5920 KB |
Output isn't correct - not an optimal way |