#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
string to_binary(int x){
string str;
for(int i=12;i>=0;i--)
str += (bool(x&(1<<i)) + '0');
return str;
}
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0;i<N;i++){
string s = to_binary(C[i]);
for(int i=0;i<13-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) {
vector<int> C;
vector<int> last(N);
for(int i=0;i<13*N;i+=13){
string s;
for(int j=0;j<13;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]});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
860 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1380 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
2156 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
333 ms |
10592 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
12272 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
373 ms |
13500 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Incorrect |
371 ms |
14916 KB |
Error - Not putting back color when it is not on the scaffold |
3 |
Incorrect |
325 ms |
15180 KB |
Error - Not putting back color when it is not on the scaffold |
4 |
Incorrect |
413 ms |
15256 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Incorrect |
312 ms |
15256 KB |
Error - Not putting back color when it is not on the scaffold |
6 |
Incorrect |
331 ms |
15332 KB |
Error - Not putting back color when it is not on the scaffold |
7 |
Incorrect |
320 ms |
15408 KB |
Error - Not putting back color when it is not on the scaffold |
8 |
Incorrect |
311 ms |
15408 KB |
Error - Not putting back color when it is not on the scaffold |
9 |
Incorrect |
365 ms |
15408 KB |
Error - Not putting back color when it is not on the scaffold |
10 |
Incorrect |
347 ms |
15408 KB |
Error - Not putting back color when it is not on the scaffold |