Submission #257744

# Submission time Handle Problem Language Result Execution time Memory
257744 2020-08-04T17:03:53 Z Noam13 Last supper (IOI12_supper) C++14
0 / 100
240 ms 9200 KB
#include "advisor.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define vb vector<bool>
#define ii pair<int,int>
#define vvi vector<vi>
#define vvb vector<vb>
#define vii vector<ii>
#define vvii vector<vii>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define loop(i,s,e) for(int i=s;i<e;i++)
#define loopr(i,s,e) for(int i=e-1;i>=s;i--)
#define chkmax(a,b) a=max(a,b)
#define chkmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
using namespace std;
const int INF = 1e9, MOD=1e9+7;

void ComputeAdvice(int *C, int n, int k, int M) {
	vi a(n+k);
	loop(i,0,k) a[i]=i;
	loop(i,0,n) a[i+k]=C[i];
    vi next(n+k);
	vi last(n, n+k+1);
	loopr(i,0,n+k) {
		next[i] = last[a[i]];
		last[a[i]] = i;
	}
	map<int, int> q;
	map<int, int> in;
	loop(i,0,k) {
		q[-next[i]] = i;
		in[i] = i;
	}
	vb bits(n+k,0);
	loop(i,k,n+k){
		if (in.find(a[i])!=in.end()){ //already in
			bits[in[a[i]]] = 1;
			q.erase(-i);
		}
		else{ //out
			ii cur = *q.begin(); q.erase(q.begin());
			bits[cur.y] = 0;
			in.erase(a[cur.y]);
		}
		q[-next[i]] =  i;
		in[a[i]] = i;
	}
	loop(i,0,n+k) WriteAdvice(bits[i]);
}
/*
color a
cls
g++ advisor.cpp -o a & a

*/
#include "assistant.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define vb vector<bool>
#define ii pair<int,int>
#define vvi vector<vi>
#define vvb vector<vb>
#define vii vector<ii>
#define vvii vector<vii>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define loop(i,s,e) for(int i=s;i<e;i++)
#define loopr(i,s,e) for(int i=e-1;i>=s;i--)
#define chkmax(a,b) a=max(a,b)
#define chkmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
using namespace std;
const int INF = 1e9, MOD=1e9+7;

void Assist(unsigned char *A, int n, int k, int R) {
	set<int> s; 
	set<int> fre;
	loop(i,0,k) {
		s.insert(i);
		if (!A[i]) fre.insert(i);
	}
	//cout<<"HI"<<endl;
	loop(i,k,n+k){
		int v = GetRequest();
		if (s.find(v)!=s.end()){
			if (fre.find(v)!=fre.end()) fre.erase(v);
		}
		else{
			int back = *fre.begin();
			PutBack(back);
			s.erase(back);
			fre.erase(back);
		}
		s.insert(v);
		if (!A[i]) fre.insert(v);
	}
}
/*
color a
cls
g++ assistant.cpp -o a & a

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 772 KB Output is correct
2 Incorrect 0 ms 644 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1356 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 169 ms 6716 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1260 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 7408 KB Output isn't correct - not an optimal way
2 Incorrect 239 ms 7792 KB Output isn't correct - not an optimal way
3 Incorrect 238 ms 8364 KB Output isn't correct - not an optimal way
4 Incorrect 240 ms 8496 KB Output isn't correct - not an optimal way
5 Incorrect 225 ms 8428 KB Output isn't correct - not an optimal way
6 Incorrect 218 ms 8440 KB Output isn't correct - not an optimal way
7 Incorrect 222 ms 8268 KB Output isn't correct - not an optimal way
8 Incorrect 224 ms 8396 KB Output isn't correct - not an optimal way
9 Incorrect 223 ms 8524 KB Output isn't correct - not an optimal way
10 Incorrect 207 ms 9200 KB Output isn't correct - not an optimal way