#include "advisor.h"
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef pair<int, int> pii;
set<pii> s;
int sca[100100];
vector <int> ans;
queue <int> q[100100];
vector <int> dectobin(int n){
vector<int> r;
for(int i = 17; i > -1; --i)
if((1 << i) <= n){
r.push_back(1);
n -= (1 << i);
}
else r.push_back(0);
return r;
}
void ComputeAdvice(int *C, int N, int K, int M){
vector <int> aux;
for(int i = 0; i < N; ++i) q[C[i]].push(-i);
for(int i = 0; i < N; ++i) q[i].push(-2*N);
for(int i = 0; i < K; ++i) s.insert(pii(q[i].front(), i));
for(int i = 0; i < N; ++i){
if(s.count(pii(q[C[i]].front(), C[i])) != 0){
s.erase(pii(q[C[i]].front(), C[i]));
q[C[i]].pop();
s.insert(pii(q[C[i]].front(), C[i]));
}
else{
ans.push_back(s.begin() -> ss);
q[C[i]].pop();
s.erase(s.begin());
s.insert(pii(q[C[i]].front(), C[i]));
}
}
for(int i = 0; i < ans.size(); ++i){
aux = dectobin(ans[i]);
for(int j = 0; j < aux. size(); ++j)
WriteAdvice(aux[j]);
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
set <int> scaf;
vector<int> bintodec(unsigned char *A, int R){
int aux = 0;
vector<int> r;
for(int i = 0; i < R && A[i] != 2; ++i){
aux += (1 << (17 - (i%18)))*(A[i] == 1);
if((i%18) == 17){
r.push_back(aux);
aux = 0;
}
}
return r;
}
void Assist(unsigned char *A, int N, int K, int R){
int cnt = 0;
vector<int> rem = bintodec(A, R);
for(int i = 0; i < K; ++i) scaf.insert(i);
for(int i = 0; i < N; ++i){
int req = GetRequest();
if(scaf.count(req)) continue;
else{
scaf.erase(rem[cnt]);
scaf.insert(req);
PutBack(rem[cnt++]);
}
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < ans.size(); ++i){
~~^~~~~~~~~~~~
advisor.cpp:45:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0; j < aux. size(); ++j)
~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
135408 KB |
Output is correct |
2 |
Correct |
72 ms |
135504 KB |
Output is correct |
3 |
Correct |
72 ms |
135656 KB |
Output is correct |
4 |
Correct |
89 ms |
136280 KB |
Output is correct |
5 |
Incorrect |
80 ms |
136280 KB |
Error - advice is too long |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
137288 KB |
Output is correct |
2 |
Correct |
232 ms |
141128 KB |
Output is correct |
3 |
Correct |
550 ms |
150328 KB |
Output is correct |
4 |
Correct |
601 ms |
152568 KB |
Output is correct |
5 |
Correct |
614 ms |
153016 KB |
Output is correct |
6 |
Correct |
550 ms |
153016 KB |
Output is correct |
7 |
Correct |
530 ms |
153016 KB |
Output is correct |
8 |
Correct |
535 ms |
154888 KB |
Output is correct |
9 |
Correct |
627 ms |
157712 KB |
Output is correct |
10 |
Correct |
575 ms |
157712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
430 ms |
157712 KB |
Output is correct |
2 |
Correct |
488 ms |
158440 KB |
Output is correct |
3 |
Correct |
515 ms |
159336 KB |
Output is correct |
4 |
Correct |
518 ms |
160224 KB |
Output is correct |
5 |
Correct |
439 ms |
160224 KB |
Output is correct |
6 |
Correct |
623 ms |
163088 KB |
Output is correct |
7 |
Correct |
553 ms |
163840 KB |
Output is correct |
8 |
Correct |
638 ms |
168432 KB |
Output is correct |
9 |
Correct |
429 ms |
168432 KB |
Output is correct |
10 |
Correct |
534 ms |
168432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
96 ms |
168432 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
683 ms |
168920 KB |
Output is partially correct - 926838 bits used |
2 |
Partially correct |
588 ms |
170072 KB |
Output is partially correct - 890514 bits used |
3 |
Partially correct |
540 ms |
171408 KB |
Output is partially correct - 854964 bits used |
4 |
Partially correct |
492 ms |
172104 KB |
Output is partially correct - 854406 bits used |
5 |
Partially correct |
482 ms |
173560 KB |
Output is partially correct - 852732 bits used |
6 |
Partially correct |
501 ms |
174592 KB |
Output is partially correct - 854586 bits used |
7 |
Partially correct |
484 ms |
175736 KB |
Output is partially correct - 853308 bits used |
8 |
Partially correct |
474 ms |
176984 KB |
Output is partially correct - 856008 bits used |
9 |
Partially correct |
579 ms |
177944 KB |
Output is partially correct - 855396 bits used |
10 |
Partially correct |
783 ms |
182400 KB |
Output is partially correct - 1341144 bits used |