Submission #419929

# Submission time Handle Problem Language Result Execution time Memory
419929 2021-06-07T18:22:21 Z faresbasbs Last supper (IOI12_supper) C++14
8 / 100
41 ms 3812 KB
#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
multiset<pair<int,int>> ms;
int k,lg,pos[100001];
set<int> st[25001];

void rt(int num){
	for(int i = lg-1 ; i >= 0 ; i -= 1){
		if(num & (1<<i)){
			WriteAdvice(1);
		}else{
			WriteAdvice(0);
		}
	}
}

void ComputeAdvice(int *C , int n , int K , int M){
	k = K , lg = ceil(log2(n+1));
	for(int i = 0 ; i < n ; i += 1){
		st[C[i]].insert(i);
		st[i].insert(n);
	}
	for(int i = 0 ; i < k ; i += 1){
		pos[i] = i;
		ms.insert({*st[i].upper_bound(-1),i});
	}
	for(int i = 0 ; i < n ; i += 1){
		if(ms.find({i,C[i]}) != ms.end()){
			ms.erase({i,C[i]});
			ms.insert({*st[C[i]].upper_bound(i),C[i]});
			rt(k);
		}else{
			pair<int,int> bd = *(--ms.end());
			ms.erase(bd);
			rt(pos[bd.second]);
			pos[C[i]] = pos[bd.second];
			ms.insert({*st[C[i]].upper_bound(i),C[i]});
		}
		/*cout << -1 << endl;
		for(auto j : ms){
			cout << j.first << " " << j.second << endl;
		}cout << endl << endl;*/
	}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
int lg2,val[100001];

void Assist(unsigned char *a , int n , int k , int R) {
	lg2 = ceil(log2(n+1));
	for(int i = 0 ; i < k ; i += 1){
		val[i] = i;
	}
	for(int i = 0 ; i < n ; i += 1){
		int num = 0 , num2 = GetRequest();
		for(int j = lg2*i ; j < lg2*(i+1) ; j += 1){
			num = 2*num;
			if(a[j] == 1){
				num += 1;
			}
		}
		if(num == k){
			continue;
		}
		PutBack(val[num]);
		val[num] = num2;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1640 KB Output is correct
2 Correct 1 ms 1768 KB Output is correct
3 Correct 4 ms 1920 KB Output is correct
4 Correct 13 ms 2356 KB Output is correct
5 Correct 18 ms 2684 KB Output is correct
6 Correct 20 ms 2768 KB Output is correct
7 Correct 20 ms 2688 KB Output is correct
8 Correct 20 ms 2688 KB Output is correct
9 Correct 20 ms 2692 KB Output is correct
10 Correct 24 ms 2728 KB Output is correct
11 Correct 20 ms 2820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 3812 KB Output is correct
2 Runtime error 9 ms 3148 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 3392 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2156 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 3592 KB Execution killed with signal 11
2 Runtime error 15 ms 3496 KB Execution killed with signal 11
3 Runtime error 15 ms 3580 KB Execution killed with signal 11
4 Runtime error 15 ms 3532 KB Execution killed with signal 11
5 Runtime error 14 ms 3532 KB Execution killed with signal 11
6 Runtime error 15 ms 3532 KB Execution killed with signal 11
7 Runtime error 14 ms 3532 KB Execution killed with signal 11
8 Runtime error 15 ms 3572 KB Execution killed with signal 11
9 Runtime error 15 ms 3612 KB Execution killed with signal 11
10 Runtime error 20 ms 3532 KB Execution killed with signal 11