/*
______ _____ _______ _ _ _______ __ _ _____ _ _ _
|_____/ | | | |____/ |______ | \ | | | | | |
| \_ |_____| |_____ | \_ ______| | \_| |_____| |__|__|
. . . . . .
_\/ \/_ _\/ \/_ _\/ \/_
_\/\/_ _\/\/_ _\/\/_
_\_\_\/\/_/_/_ _\_\_\/\/_/_/_ _\_\_\/\/_/_/_
/ /_/\/\_\ \ / /_/\/\_\ \ / /_/\/\_\ \
_/\/\_ _/\/\_ _/\/\_
/\ /\ /\ /\ /\ /\
' ' ' ' ' '
*/
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;
#include "advisor.h"
void ComputeAdvice(int *C, int N, int K, int M) {
vector<deque<int> > times(N, deque<int>());
for(int i=0; i<N; i++){
times[C[i]].push_back(i);
}
for(int i=0; i<N; i++){
times[i].push_back(1e6);
}
priority_queue<pair<int,int> > q;
set<int> d;
for(int i=0; i<K; i++){
d.insert(i);
q.push({times[i].front(),i});
}
int kk=ceil(log2(N));
for(int i=0; i<N; i++){
times[C[i]].pop_front();
if(d.find(C[i])==d.end()){
d.insert(C[i]);
int y=q.top().second; q.pop();
while(d.find(y)==d.end()){
y=q.top().second; q.pop();
}
d.erase(y);
for(int bit=0; bit<kk; bit++){
if((1<<bit)&y) WriteAdvice(1);
else WriteAdvice(0);
}
}
d.insert(C[i]);
q.push({times[C[i]].front(),C[i]});
}
}
/*
______ _____ _______ _ _ _______ __ _ _____ _ _ _
|_____/ | | | |____/ |______ | \ | | | | | |
| \_ |_____| |_____ | \_ ______| | \_| |_____| |__|__|
. . . . . .
_\/ \/_ _\/ \/_ _\/ \/_
_\/\/_ _\/\/_ _\/\/_
_\_\_\/\/_/_/_ _\_\_\/\/_/_/_ _\_\_\/\/_/_/_
/ /_/\/\_\ \ / /_/\/\_\ \ / /_/\/\_\ \
_/\/\_ _/\/\_ _/\/\_
/\ /\ /\ /\ /\ /\
' ' ' ' ' '
*/
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;
#include "assistant.h"
void Assist(unsigned char *A, int N, int K, int R) {
set<int> s;
for(int i=0; i<K; i++){
s.insert(i);
}
int c=0;
int kk=ceil(log2(N));
for (int i = 0; i < N; i++) {
int req = GetRequest();
if(s.find(req)==s.end()){
int y=0;
for(int bit=0; bit<kk; bit++){
if(A[bit+c]) y|=(1<<bit);
}
c+=kk;
PutBack(y);
s.erase(y);
}
s.insert(req);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
504 KB |
Output is correct |
2 |
Correct |
0 ms |
644 KB |
Output is correct |
3 |
Correct |
2 ms |
1408 KB |
Output is correct |
4 |
Correct |
9 ms |
2760 KB |
Output is correct |
5 |
Correct |
15 ms |
4344 KB |
Output is correct |
6 |
Correct |
17 ms |
4244 KB |
Output is correct |
7 |
Correct |
7 ms |
4264 KB |
Output is correct |
8 |
Correct |
18 ms |
4376 KB |
Output is correct |
9 |
Correct |
17 ms |
4364 KB |
Output is correct |
10 |
Correct |
13 ms |
4420 KB |
Output is correct |
11 |
Correct |
12 ms |
4328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
8032 KB |
Output is correct |
2 |
Correct |
138 ms |
37280 KB |
Output is correct |
3 |
Correct |
370 ms |
77664 KB |
Output is correct |
4 |
Correct |
417 ms |
75912 KB |
Output is correct |
5 |
Correct |
416 ms |
75608 KB |
Output is correct |
6 |
Correct |
379 ms |
75212 KB |
Output is correct |
7 |
Correct |
335 ms |
75784 KB |
Output is correct |
8 |
Correct |
330 ms |
65632 KB |
Output is correct |
9 |
Correct |
377 ms |
74524 KB |
Output is correct |
10 |
Correct |
318 ms |
76096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
256 ms |
60636 KB |
Output is correct |
2 |
Correct |
324 ms |
75744 KB |
Output is correct |
3 |
Correct |
323 ms |
75972 KB |
Output is correct |
4 |
Correct |
302 ms |
75752 KB |
Output is correct |
5 |
Correct |
251 ms |
73556 KB |
Output is correct |
6 |
Correct |
316 ms |
75784 KB |
Output is correct |
7 |
Correct |
304 ms |
75712 KB |
Output is correct |
8 |
Correct |
398 ms |
77080 KB |
Output is correct |
9 |
Correct |
246 ms |
74340 KB |
Output is correct |
10 |
Correct |
325 ms |
75728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
3336 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
328 ms |
75564 KB |
Output is partially correct - 875347 bits used |
2 |
Correct |
317 ms |
75640 KB |
Output is partially correct - 841041 bits used |
3 |
Correct |
323 ms |
75836 KB |
Output is partially correct - 807466 bits used |
4 |
Correct |
323 ms |
75776 KB |
Output is partially correct - 806939 bits used |
5 |
Correct |
324 ms |
75780 KB |
Output is partially correct - 805358 bits used |
6 |
Correct |
316 ms |
75764 KB |
Output is partially correct - 807109 bits used |
7 |
Correct |
315 ms |
75956 KB |
Output is partially correct - 805902 bits used |
8 |
Correct |
316 ms |
75752 KB |
Output is partially correct - 808452 bits used |
9 |
Correct |
321 ms |
75852 KB |
Output is partially correct - 807874 bits used |
10 |
Correct |
398 ms |
77048 KB |
Output is partially correct - 1266636 bits used |