Submission #804492

# Submission time Handle Problem Language Result Execution time Memory
804492 2023-08-03T09:06:25 Z Dan4Life Last supper (IOI12_supper) C++17
9 / 100
396 ms 24892 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
	if(M!=1500000){
		int x = *max_element(C,C+N);
		for(int i = 0; i < N; i++)
			for(int j = 0; j < (x<5000?13:20); j++)
				WriteAdvice((C[i]>>j)&1);
		return;
	}
	set<int> S; set<pair<int,int>> SS; vector<int> v[N+1];
  for(int i = 0; i < N; i++) v[C[i]].push_back(i);
  for(int i = 0; i < N; i++) v[i].push_back(N+1);
  for(int i = 0; i < K; i++){
	  int nx = *upper_bound(begin(v[i]),end(v[i]),-1);
	  S.insert(i); SS.insert({nx,i});
  }
  for(int i = 0; i < N; i++) {
	int req = C[i];
	if(S.count(req)){
		for(int j = 0; j < 15; j++) WriteAdvice(1);
		int nx = *upper_bound(begin(v[req]),end(v[req]),i);
		SS.erase({i,req}); SS.insert({nx,req});
		continue;
	}
	int getCol = (--end(SS))->second;
	S.erase(getCol); S.insert(req);
	for(int j = 0; j < 15; j++) WriteAdvice((getCol>>j)&1);
	int nx = *upper_bound(begin(v[req]),end(v[req]),i);
	SS.erase(--end(SS)); SS.insert({nx,req});
  }
  int tot = N;
  while(tot<1500000) WriteAdvice(1),tot++;
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
 
void Assist(unsigned char *A, int N, int K, int R) {
    if(R==1500000){
		for(int i = 0; i < R; i+=15){
			int xd = 0;
			for(int j = 0; j < 15; j++)
				if(A[i+j]) xd |= (1<<j);
			if(xd!=(1<<15)-1) PutBack(xd);
		}
		return;
	}
  int C[N+1]; vector<int> v[N+1];
  for(int i = 0; i < N; i++) C[i]=0;
  const int bit = R%20?13:20;
  for(int i = 0; i < R; i++)
      if(A[i]) C[i/bit] |= (1<<(i%bit));
  set<int> S; set<pair<int,int>> SS;
  for(int i = 0; i < N; i++) v[C[i]].push_back(i);
  for(int i = 0; i < N; i++) v[i].push_back(N+1);
  for(int i = 0; i < K; i++){
	  int nx = *upper_bound(begin(v[i]),end(v[i]),-1);
	  S.insert(i); SS.insert({nx,i});
  }
  for(int i = 0; i < N; i++) {
    int req = GetRequest();
    if(S.count(req)){
        int nx = *upper_bound(begin(v[req]),end(v[req]),i);
        SS.erase({i,req}); SS.insert({nx,req});
        continue;
    }
    int getCol = (--end(SS))->second;
    S.erase(getCol); S.insert(req); PutBack(getCol);
    int nx = *upper_bound(begin(v[req]),end(v[req]),i);
    SS.erase(--end(SS)); SS.insert({nx,req});
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 508 KB Output is correct
2 Runtime error 2 ms 728 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2744 KB Output is correct
2 Correct 182 ms 11528 KB Output is correct
3 Correct 390 ms 24892 KB Output is correct
4 Correct 337 ms 21660 KB Output is correct
5 Correct 348 ms 21536 KB Output is correct
6 Correct 386 ms 22032 KB Output is correct
7 Correct 376 ms 23316 KB Output is correct
8 Correct 309 ms 20560 KB Output is correct
9 Correct 338 ms 21824 KB Output is correct
10 Correct 396 ms 24340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 8448 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 516 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2672 KB Error - advice is too long
2 Incorrect 14 ms 2708 KB Error - advice is too long
3 Incorrect 14 ms 2708 KB Error - advice is too long
4 Incorrect 14 ms 2700 KB Error - advice is too long
5 Incorrect 14 ms 2700 KB Error - advice is too long
6 Incorrect 14 ms 2756 KB Error - advice is too long
7 Incorrect 14 ms 2720 KB Error - advice is too long
8 Incorrect 14 ms 2736 KB Error - advice is too long
9 Incorrect 14 ms 2700 KB Error - advice is too long
10 Incorrect 14 ms 2648 KB Error - advice is too long