Submission #419930

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

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 4 ms 5232 KB Output is correct
2 Correct 3 ms 5236 KB Output is correct
3 Correct 9 ms 5384 KB Output is correct
4 Correct 13 ms 5844 KB Output is correct
5 Correct 23 ms 6280 KB Output is correct
6 Correct 20 ms 6260 KB Output is correct
7 Correct 23 ms 6268 KB Output is correct
8 Correct 21 ms 6272 KB Output is correct
9 Correct 23 ms 6280 KB Output is correct
10 Correct 24 ms 6308 KB Output is correct
11 Correct 22 ms 6260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 7452 KB Output is correct
2 Correct 232 ms 16188 KB Output is correct
3 Correct 544 ms 30184 KB Output is correct
4 Correct 459 ms 28244 KB Output is correct
5 Correct 503 ms 28416 KB Output is correct
6 Correct 489 ms 28664 KB Output is correct
7 Correct 520 ms 29272 KB Output is correct
8 Correct 425 ms 26076 KB Output is correct
9 Correct 467 ms 27900 KB Output is correct
10 Correct 509 ms 29808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 404 ms 23844 KB Output is correct
2 Incorrect 141 ms 19048 KB Error - advice is too long
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 5724 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 530 ms 28176 KB Output is partially correct - 1700000 bits used
2 Correct 540 ms 28492 KB Output is partially correct - 1700000 bits used
3 Correct 518 ms 28704 KB Output is partially correct - 1700000 bits used
4 Correct 513 ms 28692 KB Output is partially correct - 1700000 bits used
5 Correct 507 ms 28696 KB Output is partially correct - 1700000 bits used
6 Correct 532 ms 28628 KB Output is partially correct - 1700000 bits used
7 Correct 528 ms 28464 KB Output is partially correct - 1697263 bits used
8 Correct 527 ms 28584 KB Output is partially correct - 1700000 bits used
9 Correct 515 ms 28480 KB Output is partially correct - 1700000 bits used
10 Correct 489 ms 28688 KB Output is partially correct - 1700000 bits used