Submission #870174

# Submission time Handle Problem Language Result Execution time Memory
870174 2023-11-07T06:53:40 Z HuyQuang_re_Zero Last supper (IOI12_supper) C++14
0 / 100
80 ms 12004 KB
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
#define N 200005
#include "advisor.h"
//#define WriteAdvice(k) cout<<k<<'\n';
using namespace std;
struct International_Olympiad_in_Informatics
{
    int nxt[N],request[N],i,k,n,m,c[N],pos[N],res[N],now[N];
    void Work(int c[],int n,int k,int m)
    {
        m=0;
        for(i=1;i<=k;i++) request[++m]=i;
        for(i=1;i<=n;i++) request[++m]=c[i];
        memset(pos,63,sizeof(pos));
        for(i=m;i>=1;i--) nxt[i]=pos[request[i]],pos[request[i]]=i;
        set <II> s;
        for(i=1;i<=m;i++)
        {
            int x=request[i];
         //   cout<<x<<" ";
            if(i<=k) s.insert({ nxt[i],x });
            else if(s.find({ i,x })!=s.end())
            {
                s.erase({ i,x });
                s.insert({ nxt[i],x });
            }
            else
            {
                set <II>::iterator it=s.end(); it--;
                II tg=*it; s.erase(tg);
                res[now[tg.snd]]=1;
                s.insert({ nxt[i],x });
            //    cerr<<tg.snd<<" "<<x<<'\n';
            }
            now[x]=i;
        }
      //  cout<<'\n';
    }
} IOI;
 
 
int n,k,m,c[N],i;
void ComputeAdvice(int _c[],int n,int k,int m)
{
    for(int i=n;i>=1;i--) c[i]=_c[i-1],c[i]++;
    IOI.Work(c,n,k,m);
    for(int i=1;i<=n+k;i++) WriteAdvice(IOI.res[i]);
}
/*
int main()
{
    freopen("advisor.inp","r",stdin);
    freopen("advisor.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>k>>m;
    for(i=0;i<n;i++) cin>>c[i];
    ComputeAdvice(c,n,k,m);
}
*/
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define fst first
#define snd second
#define BIT(x,i) ((x>>i)&1)
#define pi acos(-1)
#define to_radian(x) (x*pi/180.0)
#define to_degree(x) (x*180.0/pi)
#define Log(x) (31-__builtin_clz((int)x))
#define LogLL(x) (63-__builtin_clzll((ll)x))
#define N 200005
#include "assistant.h"
//#define PutBack(x) cout<<x<<'\n';
using namespace std;
struct International_Olympiad_in_Informatics
{
    int n,k,m,i,in[N];
    int a[N];
    set <int> s;
    void Init(unsigned char _a[],int _n,int _k,int _m)
    {
        n=_n; k=_k; m=_m;
        for(i=1;i<=m;i++) a[i]=_a[i]-'0';
    }
    int add(int i,int x)
    {
        if(i<=k)
        {
         //   cerr<<i<<" "<<a[i]<<'\n';
            if(a[i]==1) s.insert(x);
            in[x]=1;
            return 0;
        }
        else if(in[x]==1)
        {
            s.erase(x);
            if(a[i]==1) s.insert(x);
            in[x]=1;
            return 0;
        }
        else
        {
            int y=*s.begin(); s.erase(y);
            in[y]=0;
            if(a[i]==1) s.insert(x);
            in[x]=1;
            return y;
        }
    }
} IOI;


//int GetRequest() { int k; cin>>k; return k; }
int n,k,r,i;
unsigned char a[N];
void Assist(unsigned char _a[], int n, int k, int r)
{
    for(i=r;i>=1;i--) a[i]=_a[i-1];
    IOI.Init(a,n,k,r);
    for(i=1;i<=k;i++) IOI.add(i,i);
    for(i=k+1;i<=k+n;i++)
    {
        int x=GetRequest(),k=IOI.add(i,x+1);
        if(k>0) PutBack(k-1);
    }
}
/*
int main()
{
    freopen("assist.inp","r",stdin);
    freopen("assist.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>k>>r;
    for(i=0;i<r;i++) cin>>a[i];
    Assist(a,n,k,r);
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4884 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 5280 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 10296 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5192 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 11384 KB Error - Not putting back color when it is not on the scaffold
2 Incorrect 67 ms 11564 KB Error - Not putting back color when it is not on the scaffold
3 Incorrect 67 ms 11836 KB Error - Not putting back color when it is not on the scaffold
4 Incorrect 67 ms 11736 KB Error - Not putting back color when it is not on the scaffold
5 Incorrect 68 ms 11584 KB Error - Not putting back color when it is not on the scaffold
6 Incorrect 76 ms 11580 KB Error - Not putting back color when it is not on the scaffold
7 Incorrect 80 ms 12004 KB Error - Not putting back color when it is not on the scaffold
8 Incorrect 70 ms 11580 KB Error - Not putting back color when it is not on the scaffold
9 Incorrect 68 ms 11640 KB Error - Not putting back color when it is not on the scaffold
10 Incorrect 60 ms 11732 KB Error - Not putting back color when it is not on the scaffold