/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
#include "advisor.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro"<<i<<endl
#define INF 1000000000000000000LL
#define EPS ((ld)0.00000000001)
#define pi ((ld)3.141592653589793)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
template<class A>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
void ComputeAdvice(int *CC, int N, int K, int M)
{
vector<ll> C; REP(i,0,N) {C.pb(*(CC+i));}
vector<ll> nxt(N,N); REP(i,0,N) {nxt[C[i]]=min(nxt[C[i]],i);}
set<pl> s; REP(i,0,K) {s.insert(mp(nxt[i],i));}
vector<bool> rest(N,false);
vector<vector<ll> > pos(N,vector<ll>(0));
REP(i,0,N) {pos[C[i]].pb(i);}
REP(i,0,N) {pos[i].pb(N);}
set<pl>::iterator it,it2; ll cur;
REP(i,0,N)
{
cur=C[i];
it=s.lower_bound(mp(nxt[cur],cur));
if(it!=s.end() && it->ss==cur)
{
rest[i]=true; nxt[cur]=*upper_bound(whole(pos[cur]),i);
s.erase(it); s.insert(mp(nxt[cur],cur));
}
else
{
it2=s.end(); it2--; s.erase(it2);
nxt[cur]=*upper_bound(whole(pos[cur]),i);
s.insert(mp(nxt[cur],cur));
}
}
ll ind;
REP(i,0,K)
{
ind=pos[i][0]; if(ind==N || !rest[ind]) {WriteAdvice(0);} else {WriteAdvice(1);}
}
REP(i,0,N)
{
cur=C[i];
ind=*upper_bound(whole(pos[cur]),i);
if(ind==N || !rest[ind]) {WriteAdvice(0);} else {WriteAdvice(1);}
}
}
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
#include "assistant.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro"<<i<<endl
#define INF 1000000000000000000LL
#define EPS ((ld)0.00000000001)
#define pi ((ld)3.141592653589793)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007LL;
template<class A>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
void Assist(unsigned char *AA, int N, int K, int R)
{
vector<bool> A(K+N,false); REP(i,0,K+N) {if(*(AA+i)=='1') {A[i]=true;}}
vector<ll> trash; set<ll> good; REP(i,0,K) {if(A[i]) {good.insert(i);} else {trash.pb(i);}}
ll needed;
REP(i,0,N)
{
needed=GetRequest();
if(good.find(needed)!=good.end())
{
if(!A[K+i]) {good.erase(good.find(needed)); trash.pb(needed);}
}
else
{
PutBack(trash.back()); trash.pop_back();
if(A[K+i]) {good.insert(needed);} else {trash.pb(needed);}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
516 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
1732 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
82 ms |
9676 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1176 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
111 ms |
11556 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
102 ms |
11688 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
114 ms |
11880 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
125 ms |
11896 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
113 ms |
11880 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
110 ms |
11944 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
110 ms |
11876 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
126 ms |
11988 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
116 ms |
11964 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
94 ms |
11520 KB |
Error - Putting back a color when it is already on the scaffold |