Submission #73720

# Submission time Handle Problem Language Result Execution time Memory
73720 2018-08-28T18:20:02 Z FLDutchman Last supper (IOI12_supper) C++14
0 / 100
315 ms 26888 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

typedef int INT;

#define pb push_back
#define fst first
#define snd second
#define FOR(i,l,r) for(int i = (l); i < (r); i++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
int NUM_BITS;

priority_queue<int> q;
vi C;
void ComputeAdvice(int *c, int N, int K, int M) {
	FOR(i,0,N) C.pb(c[i]);
	FOR(i,0,N) C.pb(i);
	NUM_BITS = K <= 5000 ? 13 : 15;
	vi ne(N, -1), last(N,-1);
	FOR(i,0,C.size()){
		if(last[C[i]] != -1) ne[last[C[i]]] = i;
		last[C[i]] = i;
	}
	//for(int k : ne) cout << k << endl;
	vi idx(N, -1);
	for(int i = 0; i < C.size(); i++) {
		if(C[i] < K and idx[C[i]] == -1) {
			q.push(i);
			idx[C[i]] = C[i];
		}
	}
	//FOR(i,0,K) cout << idx[i] << endl;
	FOR(i, 0, N) {
		if(idx[C[i]] == -1){
			int t = q.top();
			q.pop();
			q.push(ne[i]);
			idx[C[i]] = idx[C[t]];
			idx[C[t]] = -1;
			int n = idx[C[i]];

			FOR(i, 0, NUM_BITS) {
				WriteAdvice((n>>i)&1);
			}
		}
	}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

typedef int INT;

#define pb push_back
#define fst first
#define snd second
#define FOR(i,l,r) for(int i = (l); i < (r); i++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int nb;

void Assist(unsigned char *A, int N, int K, int R) {
	int k = 0;
	nb = K <= 5000 ? 13 : 15;
 	vi idx(N, -1);
 	vi arr(K, 0);
 	FOR(i, 0, K) idx[i] = arr[i] = i;
 	FOR(i, 0, N){
 		int t = GetRequest();
 		if(idx[t] == -1) {
 			int n = 0;
 			FOR(i, 0, nb) n += A[k++] << i;
 			//cout << arr[n] << endl;
 			PutBack(arr[n]);
 			int an = arr[n];
 			arr[n] = t;
 			idx[an] = -1;
 			idx[t] = n;
 		}
 	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:11:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(i,l,r) for(int i = (l); i < (r); i++)
                                       ^
advisor.cpp:26:2: note: in expansion of macro 'FOR'
  FOR(i,0,C.size()){
  ^~~
advisor.cpp:32:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < C.size(); i++) {
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 880 KB Output is correct
2 Incorrect 7 ms 1000 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2176 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 245 ms 11664 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 11664 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 280 ms 15632 KB Output isn't correct - not an optimal way
2 Incorrect 266 ms 16592 KB Output isn't correct - not an optimal way
3 Incorrect 252 ms 17672 KB Output isn't correct - not an optimal way
4 Incorrect 232 ms 18568 KB Output isn't correct - not an optimal way
5 Incorrect 239 ms 19784 KB Output isn't correct - not an optimal way
6 Incorrect 262 ms 21032 KB Output isn't correct - not an optimal way
7 Incorrect 269 ms 22384 KB Output isn't correct - not an optimal way
8 Incorrect 315 ms 23528 KB Output isn't correct - not an optimal way
9 Incorrect 248 ms 24408 KB Output isn't correct - not an optimal way
10 Partially correct 315 ms 26888 KB Output is partially correct - 1117620 bits used