# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
272108 |
2020-08-18T09:03:38 Z |
최은수(#5096) |
최후의 만찬 (IOI12_supper) |
C++14 |
|
2500 ms |
2220 KB |
#include"advisor.h"
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
void ComputeAdvice(int*C,int N,int K,int M)
{
set<pi,greater<pi> >st;
vector<int>v(N,N);
vector<int>nx=v;
for(int i=N;i-->0;)
nx[i]=v[C[i]],v[C[i]]=i;
vector<int>adv(N,0);
vector<bool>chk(N,0);
for(int i=0;i<N;i++)
{
if(nx[i]==N)
adv[i]=0;
else
{
int cnt=0,mxcnt=0;
for(int j=i+1;j<nx[i];j++)
{
if(adv[j]==0)
{
if(chk[C[j]])
chk[C[j]]=0,cnt--;
continue;
}
if(!chk[C[j]])
chk[C[j]]=1,mxcnt=max(mxcnt,++cnt);
}
if(mxcnt<K)
adv[i]=1;
else
adv[i]=0;
for(int j=i+1;j<nx[i];j++)
chk[C[j]]=0;
}
}
vector<int>kadv(K,1);
vector<int>lst;
for(int i=0;i<K;i++)
{
if(v[i]!=N)
lst.eb(i);
else
kadv[i]=0;
}
sort(all(lst),[&](const int&x,const int&y){return v[x]<v[y];});
for(int i=0;i<(int)lst.size();i++)
{
int t=lst[i];
int cnt=0,mxcnt=0;
for(int j=0;j<(int)lst.size();j++)
{
if(kadv[lst[j]]==0)
{
if(chk[lst[j]])
chk[lst[j]]=0,cnt--;
continue;
}
if(!chk[lst[j]])
chk[lst[j]]=1,mxcnt=max(mxcnt,++cnt);
}
for(int j=0;j<v[t];j++)
{
if(adv[j]==0)
{
if(chk[C[j]])
chk[C[j]]=0,cnt--;
continue;
}
if(!chk[C[j]])
chk[C[j]]=1,mxcnt=max(mxcnt,++cnt);
}
if(mxcnt<K)
kadv[t]=1;
else
kadv[t]=0;
for(int j=0;j<(int)lst.size();j++)
chk[lst[j]]=0;
for(int j=0;j<v[t];j++)
chk[C[j]]=0;
}
for(int i=0;i<K;i++)
WriteAdvice(kadv[i]);
for(int i=0;i<N;i++)
WriteAdvice(adv[i]);
return;
}
#include"assistant.h"
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
void Assist(unsigned char*A,int N,int K,int R)
{
set<int>v1;
queue<int>v2;
for(int i=0;i<K;i++)
{
if(A[i]==1)
v1.ep(i);
else
v2.ep(i);
}
for(int i=0;i<N;i++)
{
int c=GetRequest();
auto it=v1.find(c);
if(it==v1.end())
{
PutBack(v2.front());
v2.pop();
}
else
v1.erase(it);
if(A[i+K]==1)
v1.ep(c);
else
v2.ep(c);
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1172 KB |
Output is correct |
2 |
Correct |
0 ms |
644 KB |
Output is correct |
3 |
Correct |
7 ms |
780 KB |
Output is correct |
4 |
Incorrect |
4 ms |
988 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
111 ms |
1452 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2556 ms |
1536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
944 KB |
Output is correct |
2 |
Correct |
34 ms |
1056 KB |
Output is correct |
3 |
Incorrect |
24 ms |
1064 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2564 ms |
1920 KB |
Time limit exceeded |
2 |
Execution timed out |
2574 ms |
1920 KB |
Time limit exceeded |
3 |
Execution timed out |
2579 ms |
1920 KB |
Time limit exceeded |
4 |
Execution timed out |
2572 ms |
1920 KB |
Time limit exceeded |
5 |
Execution timed out |
2532 ms |
1920 KB |
Time limit exceeded |
6 |
Execution timed out |
2574 ms |
1920 KB |
Time limit exceeded |
7 |
Execution timed out |
2582 ms |
1912 KB |
Time limit exceeded |
8 |
Execution timed out |
2555 ms |
1920 KB |
Time limit exceeded |
9 |
Execution timed out |
2564 ms |
1920 KB |
Time limit exceeded |
10 |
Execution timed out |
2566 ms |
2220 KB |
Time limit exceeded |