#include <bits/stdc++.h>
#ifndef ARTHUR_LOCAL
#include "advisor.h"
#endif
using namespace std;
#ifdef ARTHUR_LOCAL
void WriteAdvice(int n)
{
cout << n << endl;
}
#endif
void ComputeAdvice(int *C, int n, int k, int m)
{
for(int i=0; i<n; i++)
{
for(int b=0; b<13; b++)
{
if(1<<b & C[i]) WriteAdvice(1);
else WriteAdvice(0);
}
}
}
#ifdef ARTHUR_LOCAL
int main()
{
int C[4];
vector<int> to_c = {2,0,3,0};
for(int i=0; i<4; i++) C[i]=to_c[i];
ComputeAdvice(C,4,2,100);
}
#endif
#include <bits/stdc++.h>
#ifndef ARTHUR_LOCAL
#include "assistant.h"
#endif
using namespace std;
const int INF = 1000000000;
#ifdef ARTHUR_LOCAL
void PutBack(int n)
{
cout << n << endl;
}
int GetRequest()
{
return 69;
}
#endif
void Assist(unsigned char *A, int n, int k, int r)
{
vector<int> C;
unsigned char CHAR = '1';
for(int i=0; i<n; i++)
{
int cur=0;
for(int b=0; b<13; b++)
{
if(A[i*13 + b]==CHAR) cur += 1<<b;
}
C.push_back(cur);
}
// now we actually have to use the optimal strat ...
vector<bool> on_scaff(n+1);
for(int i=0; i<k; i++) on_scaff[i]=1;
priority_queue<pair<int,int>> scaff;
vector<int> next_col_occ(n+1,INF);
vector<int> next_occ(n+1,INF);
for(int i=n-1; i>=0; i--)
{
// if(i<k) scaff.push({next_col_occ[C[i]],C[i]});
next_occ[i]=next_col_occ[C[i]];
next_col_occ[C[i]]=i;
}
for(int i=0; i<k; i++) scaff.push({next_col_occ[i],i});
int ans=0;
for(int i=0; i<n; i++)
{
int do_nothing = GetRequest();
if(on_scaff[C[i]]) continue;
else
{
ans++;
PutBack(scaff.top().second);
on_scaff[scaff.top().second]=0;
scaff.pop();
on_scaff[C[i]]=1;
scaff.push({next_occ[i],C[i]});
}
}
}
#ifdef ARTHUR_LOCAL
int main()
{
unsigned char A[52];
A[1]='1';
A[26]='1';
A[27]='1';
Assist(A,4,2,52);
}
#endif
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:67:7: warning: unused variable 'do_nothing' [-Wunused-variable]
int do_nothing = GetRequest();
^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
860 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
34 ms |
1836 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
240 ms |
10096 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
752 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
298 ms |
12280 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Incorrect |
299 ms |
12204 KB |
Error - Not putting back color when it is not on the scaffold |
3 |
Incorrect |
305 ms |
12224 KB |
Error - Not putting back color when it is not on the scaffold |
4 |
Incorrect |
300 ms |
12344 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Incorrect |
300 ms |
12312 KB |
Error - Not putting back color when it is not on the scaffold |
6 |
Incorrect |
299 ms |
12128 KB |
Error - Not putting back color when it is not on the scaffold |
7 |
Incorrect |
297 ms |
12364 KB |
Error - Not putting back color when it is not on the scaffold |
8 |
Incorrect |
298 ms |
12488 KB |
Error - Not putting back color when it is not on the scaffold |
9 |
Incorrect |
298 ms |
12268 KB |
Error - Not putting back color when it is not on the scaffold |
10 |
Incorrect |
297 ms |
12264 KB |
Error - Not putting back color when it is not on the scaffold |