#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
string to_binary(int x){
string str;
int l = 31 - __builtin_clz(x);
for(int i=l;i>=0;i--)
str += (bool(x&(1<<i)) + '0');
return str;
}
void ComputeAdvice(int *C, int N, int K, int M) {
int digits = (32 - __builtin_clz(N));
for(int i=0;i<N;i++){
string s = to_binary(C[i]);
for(int i=0;i<digits-int(s.size());i++) WriteAdvice(0);
for(auto& e : s)
WriteAdvice(e-'0');
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
int to_int(string const& s){
int ans=0, ct=0;
for(int i=s.size()-1;i>=0;i--)
ans += ((s[i]-'0') * (1<<ct)), ++ct;
return ans;
}
const int inf = 0x3f3f3f3f;
void Assist(unsigned char *A, int N, int K, int R) {
int digits = (32 - __builtin_clz(N));
vector<int> C;
vector<int> last(N);
for(int i=0;i<digits*N;i+=digits){
string s;
for(int j=0;j<digits;j++)
s += (A[j+i]+'0');
C.push_back(to_int(s));
}
for(int i=0;i<N;i++)
last[i] = 0x3f3f3f3f;
for(int i=0;i<N;i++)
last[C[i]] = i;
set<pair<int, int>, greater<pair<int, int>>> conj;
for(int i=0;i<K;i++)
conj.insert({last[i], i});
for(int i=0;i<N;i++){
GetRequest();
if(conj.find({last[C[i]], C[i]}) != conj.end())
continue;
auto it = conj.begin();
PutBack(it->second);
conj.erase(it);
if(last[C[i]] == i) last[C[i]] = 0x3f3f3f3f;
conj.insert({last[C[i]], C[i]});
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
872 KB |
Output is correct |
2 |
Execution timed out |
2554 ms |
263168 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2587 ms |
263168 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
158 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
221 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Execution timed out |
2534 ms |
263168 KB |
Time limit exceeded |
3 |
Runtime error |
200 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
4 |
Runtime error |
241 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
5 |
Runtime error |
218 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
6 |
Runtime error |
236 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
7 |
Execution timed out |
2550 ms |
263168 KB |
Time limit exceeded |
8 |
Runtime error |
193 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
9 |
Runtime error |
202 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
10 |
Runtime error |
218 ms |
263168 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |