#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 1e5 + 50;
const int oo = 1e9;
vector<int> lst[nax];
set<pair<int,int>> st;
bool in[nax],rem[nax];
void ComputeAdvice(int *C, int n, int k, int M) {
for(int i=0;i<n;i++)
lst[i].push_back(oo);
for(int i=n-1;i>=0;i--)
lst[C[i]].push_back(i);
for(int i=0;i<k;i++){
st.insert({-lst[i].back(),i});
lst[i].pop_back();
in[i] = 1;
}
vector<pair<int,int>> w;
for(int i=0;i<n;i++){
if(in[C[i]] == 1){
w.push_back({1,-1});
st.erase(--st.end());
int id = C[i];
st.insert({-lst[id].back(),id});
lst[id].pop_back();
}else{
w.push_back({0,C[i]});
int id = st.begin()->second;
in[id] = 0;
in[C[i]] = 1;
if(id < k)
rem[id] = 1;
st.erase(st.begin());
lst[C[i]].pop_back();
st.insert({-lst[C[i]].back(),C[i]});
}
}
for(int i=n-1;i>=0;i--){
if(w[i].first == 0){
w[i].second = in[C[i]];
in[C[i]] = 0;
}
}
for(int i=0;i<k;i++){
WriteAdvice(rem[i]);
// cout << rem[i] << ' ';
}
for(int i=0;i<n;i++){
if(w[i].first == 1){
WriteAdvice(1);
// cout << 1 << ' ';
}else{
WriteAdvice(0);
WriteAdvice(w[i].second);
// cout << 0 << ' ' << w[i].second << ' ';
}
}
}
#include "assistant.h"
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 1e5 + 50;
const int oo = 1e9;
void Assist(unsigned char *A, int n, int k, int R) {
int at = 0;
vector<int> r,t;
for(int i=0;i<k;i++){
if(A[i] == 1){
r.push_back(i);
}
}
at = k;
for(int i=0;i<n;i++){
int req = GetRequest();
if(A[at] == 0){
at++;
PutBack(r.back());
r.pop_back();
if(A[at] == 0)
r.push_back(req);
}
at++;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5376 KB |
Output is correct |
2 |
Incorrect |
7 ms |
5376 KB |
Error - Not putting back color when it is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
6912 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
154 ms |
15696 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
6144 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
191 ms |
17248 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Incorrect |
184 ms |
17664 KB |
Error - Not putting back color when it is not on the scaffold |
3 |
Incorrect |
189 ms |
17936 KB |
Error - Not putting back color when it is not on the scaffold |
4 |
Incorrect |
166 ms |
17632 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Incorrect |
185 ms |
17680 KB |
Error - Not putting back color when it is not on the scaffold |
6 |
Incorrect |
206 ms |
17632 KB |
Error - Not putting back color when it is not on the scaffold |
7 |
Incorrect |
187 ms |
17680 KB |
Error - Not putting back color when it is not on the scaffold |
8 |
Incorrect |
208 ms |
17600 KB |
Error - Not putting back color when it is not on the scaffold |
9 |
Incorrect |
184 ms |
17976 KB |
Error - Not putting back color when it is not on the scaffold |
10 |
Incorrect |
171 ms |
17592 KB |
Error - Not putting back color when it is not on the scaffold |