// ~ 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], inq[maxn5];
void Assist(unsigned char *A, int n, int k, int r){
for(int i = 0; i < k; i++) if(A[i]){
inq[i] = mark[i] = true;
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] = inq[v] = false;
}
mark[req] = true;
if(A[i + k] && !inq[req]){
av.pb(req);
inq[req] = true;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
5252 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
5852 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
42 ms |
9572 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
5592 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
52 ms |
10592 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
52 ms |
10628 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
55 ms |
10644 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
51 ms |
10780 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
55 ms |
10588 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
50 ms |
10620 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
55 ms |
10720 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
51 ms |
10608 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
55 ms |
10656 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
50 ms |
11784 KB |
Error - Putting back a color when it is already on the scaffold |