Submission #23781

# Submission time Handle Problem Language Result Execution time Memory
23781 2017-05-25T20:20:28 Z Hiasat Last supper (IOI12_supper) C++14
20 / 100
479 ms 27120 KB
#include <bits/stdc++.h>
#include "advisor.h"

using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
	int bits = M/N;
	bits = min(bits,17);
	for (int i = 0; i < N; ++i){
		for(int k = bits-1; k >= 0 ; k--){
			bool r = C[i]&(1<<k);
			WriteAdvice(r);
		}
	}
}
#include <bits/stdc++.h>
#include "assistant.h"

using namespace std;

typedef pair<int,int> pii;

vector<int> nxt[100001];

int n , k , r;

bool have[100001];

int go(int color,int cur){
	vector<int>::iterator it = upper_bound(nxt[color].begin(),nxt[color].end(),cur);
	if(it == nxt[color].end())
		return n;
	return *it;
}
void Assist(unsigned char *A, int N, int K, int R) {
	n = N;
	k = K;
	r = R;
	int bits = min(17,R/N);
	for (int i = 0; i < N; ++i) {
		int num = 0;
		for (int k = bits-1 ; k >= 0 ; k--) {
			num += A[i * bits + ((bits-1) - k)] * (1 << k);
		}
		nxt[num].push_back(i);
	}
	set< pii > q;
	for (int i = 0; i < K; ++i){
		have[i] = 1;
		q.insert(make_pair(go(i,-1),i));
	}
	for (int i = 0; i < N; i++) {
		int req = GetRequest();
		if(have[req]){
			q.erase(make_pair(go(req,i-1),req));
			q.insert(make_pair(go(req,i),req));
			continue;
		}
		pii src = (*(--q.end()));
		q.erase(src);
		PutBack(src.second);
		have[src.second] = 0;
		have[req] = 1;
		q.insert(make_pair(go(req,i),req));
	}

}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3172 KB Output is correct
2 Correct 6 ms 5624 KB Output is correct
3 Correct 10 ms 5892 KB Output is correct
4 Correct 17 ms 6236 KB Output is correct
5 Correct 20 ms 6412 KB Output is correct
6 Correct 20 ms 6512 KB Output is correct
7 Correct 31 ms 6580 KB Output is correct
8 Correct 20 ms 6744 KB Output is correct
9 Correct 20 ms 6872 KB Output is correct
10 Correct 23 ms 6872 KB Output is correct
11 Correct 23 ms 6872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 7348 KB Output is correct
2 Correct 217 ms 10880 KB Output is correct
3 Correct 452 ms 20528 KB Output is correct
4 Correct 420 ms 27120 KB Output is correct
5 Correct 454 ms 27120 KB Output is correct
6 Correct 442 ms 27120 KB Output is correct
7 Correct 451 ms 27120 KB Output is correct
8 Correct 384 ms 27120 KB Output is correct
9 Correct 401 ms 27120 KB Output is correct
10 Correct 469 ms 27120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 357 ms 27120 KB Output is correct
2 Incorrect 400 ms 27120 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 27120 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 457 ms 27120 KB Output is partially correct - 1700000 bits used
2 Partially correct 464 ms 27120 KB Output is partially correct - 1700000 bits used
3 Partially correct 465 ms 27120 KB Output is partially correct - 1700000 bits used
4 Partially correct 457 ms 27120 KB Output is partially correct - 1700000 bits used
5 Partially correct 471 ms 27120 KB Output is partially correct - 1700000 bits used
6 Partially correct 468 ms 27120 KB Output is partially correct - 1700000 bits used
7 Partially correct 455 ms 27120 KB Output is partially correct - 1697263 bits used
8 Partially correct 464 ms 27120 KB Output is partially correct - 1700000 bits used
9 Partially correct 479 ms 27120 KB Output is partially correct - 1700000 bits used
10 Partially correct 454 ms 27120 KB Output is partially correct - 1700000 bits used