#include"advisor.h"
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
void ComputeAdvice(int*C,int N,int K,int M)
{
map<pi,int,greater<pi> >st;
vector<int>v(N,N);
vector<int>nx=v;
for(int i=N;i-->0;)
nx[i]=v[C[i]],v[C[i]]=i;
for(int i=0;i<K;i++)
st[pi(v[i],i)]=i;
vector<int>adv(N+K,1);
for(int i=0;i<N;i++)
{
auto it=st.find(pi(i,C[i]));
if(it==st.end())
{
it=st.begin();
adv[it->se]=0;
}
st.erase(it);
st[pi(nx[i],C[i])]=N+i;
}
for(auto t:st)
adv[t.se]=0;
for(int&t:adv)
WriteAdvice(t);
return;
}
#include"assistant.h"
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
void Assist(unsigned char*A,int N,int K,int R)
{
set<int>v1;
queue<int>v2;
for(int i=0;i<K;i++)
{
if(A[i]==1)
v1.ep(i);
else
v2.ep(i);
}
for(int i=0;i<N;i++)
{
int c=GetRequest();
auto it=v1.find(c);
if(it==v1.end())
{
PutBack(v2.front());
v2.pop();
}
else
v1.erase(it);
if(A[i+K]==1)
v1.ep(c);
else
v2.ep(c);
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
1572 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
46 ms |
5388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1208 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
54 ms |
5920 KB |
Execution killed with signal 11 |
2 |
Incorrect |
112 ms |
7160 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Runtime error |
58 ms |
6540 KB |
Execution killed with signal 11 |
4 |
Runtime error |
71 ms |
6616 KB |
Execution killed with signal 11 |
5 |
Runtime error |
70 ms |
6580 KB |
Execution killed with signal 11 |
6 |
Runtime error |
60 ms |
6540 KB |
Execution killed with signal 11 |
7 |
Runtime error |
73 ms |
6588 KB |
Execution killed with signal 11 |
8 |
Runtime error |
63 ms |
6568 KB |
Execution killed with signal 11 |
9 |
Runtime error |
71 ms |
6540 KB |
Execution killed with signal 11 |
10 |
Runtime error |
44 ms |
6584 KB |
Execution killed with signal 11 |