// ~ Be Name Khoda ~ //
#include <bits/stdc++.h>
#include "advisor.h"
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
static const int maxn5 = 2e5 + 10;
namespace fen{
int fen[maxn5];
inline void add(int id, int val){
for(++id; id < maxn5; id += id & -id)
fen[id] += val;
}
inline int get(int id){
if(id < 0)
return 0;
int ret = 0;
for(++id; id; id -= id & -id)
ret += fen[id];
return ret;
}
}
static vector <int> av[maxn5];
void ComputeAdvice(int *C, int n, int k, int m){
for(int i = n - 1; i >= 0; i--)
av[C[i]].pb(i);
for(int i = 0; i < n; i++) if(av[i].size())
fen::add(i, 1);
for(int i = 0; i < k; i++){
int last = n;
if(av[i].size())
last = av[i].back();
int diff = fen::get(last - 1);
WriteAdvice(char('0' + diff >= k || last == n));
//cout << "ok " << i << ' ' << last << ' ' << diff << endl;
}
for(int i = 0; i < n; i++){
av[C[i]].pop_back();
fen::add(i, -1);
int last = n;
if(av[C[i]].size()){
last = av[C[i]].back();
fen::add(last, 1);
}
int diff = fen::get(last - 1);
WriteAdvice(char('0' + last == n || diff >= k));
}
}
// ~ Be Name Khoda ~ //
#include "assistant.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
static const int maxn5 = 2e5 + 10;
static vector <int> av;
static bool mark[maxn5];
void Assist(unsigned char *A, int n, int k, int r){
fill(mark, mark + k, true);
for(int i = 0; i < k; i++) if(A[i])
av.pb(i);
for(int i = 0; i < n; i++){
int req = GetRequest();
if(!mark[req]){
if(av.empty()){
cout << "Wrong algorithm " << i << endl;
exit(0);
}
int v = av.back();
av.pop_back();
PutBack(v);
mark[v] = false;
}
mark[req] = true;
if(A[i + k])
av.pb(req);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5268 KB |
Output is correct |
2 |
Incorrect |
4 ms |
5268 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
5896 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
10616 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
5644 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
53 ms |
12036 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
52 ms |
11980 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
53 ms |
12028 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
52 ms |
11960 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
70 ms |
11972 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
55 ms |
11976 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
54 ms |
11988 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
51 ms |
11948 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
53 ms |
11996 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
52 ms |
13216 KB |
Error - Putting back a color that is not on the scaffold |