답안 #121998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121998 2019-06-27T10:41:30 Z baluteshih 최후의 만찬 (IOI12_supper) C++14
100 / 100
263 ms 144112 KB
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#include "advisor.h"
deque<int> pl[100005];
vector<int> seq;
set<pii> pq;
bitset<100005> inq,brk,beg;
int nw[100005],ls[100005];

void ComputeAdvice(int *C, int N, int K, int M)
{
	int L=__lg(K),cnt=0;
	for(int i=0;i<N;++i)
		pl[C[i]].pb(i);
	for(int i=0;i<N;++i)
		pl[i].pb(N);
	for(int i=0;i<K;++i)
		inq[i]=1,pq.insert(MP(pl[i][0],i)),nw[i]=i,ls[i]=-1;
	for(int i=0;i<N;++i)
		if(inq[C[i]])
		{
			if(!~ls[C[i]])
				beg[C[i]]=1;
			else
				brk[ls[C[i]]]=1;
			ls[C[i]]=i,pq.erase(MP(i,C[i])),pl[C[i]].pop_front(),pq.insert(MP(pl[C[i]][0],C[i]));
		} 
		else
		{
			auto tmp=--pq.end();
			inq[tmp->S]=0,nw[C[i]]=nw[tmp->S],pq.erase(tmp),pl[C[i]].pop_front();
			pq.insert(MP(pl[C[i]][0],C[i])),inq[C[i]]=1,ls[C[i]]=i;
		}
	for(int i=0;i<K;++i)
		WriteAdvice(beg[i]);
	for(int i=0;i<N;++i)
		WriteAdvice(brk[i]);
}
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#include "assistant.h"

int nnw[100005],rrel[100005];
set<int> s;

void Assist(unsigned char *A, int N, int K, int R)
{
	for(int i=0;i<K;++i)
	{
		nnw[i]=i,rrel[i]=i;
		if(!A[i])
			s.insert(i);
	}
	for(int i=0;i<N;++i)
	{
		int cur=GetRequest(),g;
		if(rrel[nnw[cur]]!=cur)
		{
			g=*s.begin(),s.erase(s.begin());
			PutBack(rrel[g]),rrel[g]=cur,nnw[cur]=g;
		}
		else g=nnw[cur];
		if(!A[i+K]) s.insert(g);
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:25:6: warning: unused variable 'L' [-Wunused-variable]
  int L=__lg(K),cnt=0;
      ^
advisor.cpp:25:16: warning: unused variable 'cnt' [-Wunused-variable]
  int L=__lg(K),cnt=0;
                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 135408 KB Output is correct
2 Correct 65 ms 135424 KB Output is correct
3 Correct 68 ms 135400 KB Output is correct
4 Correct 68 ms 135408 KB Output is correct
5 Correct 69 ms 135568 KB Output is correct
6 Correct 68 ms 135920 KB Output is correct
7 Correct 68 ms 135864 KB Output is correct
8 Correct 68 ms 135664 KB Output is correct
9 Correct 81 ms 135664 KB Output is correct
10 Correct 73 ms 135664 KB Output is correct
11 Correct 71 ms 135632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 136064 KB Output is correct
2 Correct 135 ms 138480 KB Output is correct
3 Correct 222 ms 144112 KB Output is correct
4 Correct 208 ms 140864 KB Output is correct
5 Correct 172 ms 140784 KB Output is correct
6 Correct 191 ms 141296 KB Output is correct
7 Correct 215 ms 142576 KB Output is correct
8 Correct 201 ms 142320 KB Output is correct
9 Correct 162 ms 140784 KB Output is correct
10 Correct 263 ms 143600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 141344 KB Output is correct
2 Correct 236 ms 142832 KB Output is correct
3 Correct 255 ms 143120 KB Output is correct
4 Correct 235 ms 143088 KB Output is correct
5 Correct 231 ms 142832 KB Output is correct
6 Correct 225 ms 143032 KB Output is correct
7 Correct 232 ms 143344 KB Output is correct
8 Correct 231 ms 143096 KB Output is correct
9 Correct 219 ms 143088 KB Output is correct
10 Correct 232 ms 143240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 135664 KB Output is correct
2 Correct 68 ms 135600 KB Output is correct
3 Correct 80 ms 135416 KB Output is correct
4 Correct 81 ms 135664 KB Output is correct
5 Correct 79 ms 135408 KB Output is correct
6 Correct 70 ms 135408 KB Output is correct
7 Correct 72 ms 135664 KB Output is correct
8 Correct 80 ms 135664 KB Output is correct
9 Correct 72 ms 135920 KB Output is correct
10 Correct 72 ms 135920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 142664 KB Output is correct - 120000 bits used
2 Correct 230 ms 142832 KB Output is correct - 122000 bits used
3 Correct 242 ms 142904 KB Output is correct - 125000 bits used
4 Correct 227 ms 143464 KB Output is correct - 125000 bits used
5 Correct 248 ms 143280 KB Output is correct - 125000 bits used
6 Correct 247 ms 143088 KB Output is correct - 125000 bits used
7 Correct 231 ms 143088 KB Output is correct - 124828 bits used
8 Correct 238 ms 143432 KB Output is correct - 124910 bits used
9 Correct 262 ms 143088 KB Output is correct - 125000 bits used
10 Correct 238 ms 143184 KB Output is correct - 125000 bits used