#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int n = N, k = K;
int last[N];
fill(last, last + N, n + 1);
set <int> st;
vector <int> vec;
for(int i = N - 1; i >= 0; i--){
int x = last[C[i]];
st.erase(x);
st.insert(i);
last[C[i]] = i;
if(st.size() > k)
vec.pb(1), st.erase(*st.rbegin());
else vec.pb(0);
}
for(int i = k - 1; i >= 0; i--){
if(st.find(last[i]) == st.end()){
vec.pb(1);
}
else vec.pb(0);
}
for(int i = vec.size() - 1; i >= 0; i--)
WriteAdvice(vec[i]);
}
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
int n = N, k = K;
queue <int> q;
vector <bool> used(n, false);
for(int i = 0; i < k; i++){
if(A[i] == 1)
q.push(i);
used[i] = true;
}
int val = k;
for(int i = k; i < n + k; i++){
int x = GetRequest();
if(!used[x])val++;
if(val > k){
int v = q.front();
PutBack(v);
used[v] = false;
q.pop();
val--;
}
used[x] = true;
if(A[i] == 1)
q.push(x);
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:23:22: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
23 | if(st.size() > k)
| ~~~~~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
520 KB |
Output is correct |
2 |
Incorrect |
0 ms |
520 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1156 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
55 ms |
5004 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
812 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
67 ms |
5892 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
65 ms |
5968 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
76 ms |
6192 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
68 ms |
6160 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
67 ms |
6276 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
72 ms |
6100 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
72 ms |
6096 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
72 ms |
6080 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
69 ms |
6156 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
67 ms |
6204 KB |
Output isn't correct - not an optimal way |