Submission #928401

# Submission time Handle Problem Language Result Execution time Memory
928401 2024-02-16T10:21:53 Z Tuanlinh123 Last supper (IOI12_supper) C++17
0 / 100
94 ms 14788 KB
#include "advisor.h"
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

void ComputeAdvice(int *c, int n, int k, int m) 
{ 
    vector <ll> cnt(n+k, 0), a(k), p(n);
    iota(a.begin(), a.end(), n);
    for (ll i=0; i<n; i++) p[i]=i<k?i:-1;
    vector <vector <ll>> pos(n);
    for (ll i=n-1; i>=0; i--) pos[c[i]].pb(i);
    auto get=[&](ll i) {return pos[i].size()?pos[i].back():n+1;};
    set <pll> s;
    for (ll i=0; i<k; i++) 
        s.insert({get(i), i});
    for (ll i=0; i<n; i++)
    {
        if (p[c[i]]!=-1)
        {
            cnt[a[p[c[i]]]]++;
            s.erase(s.find({get(c[i]), c[i]}));
            pos[c[i]].pop_back();
            s.insert({get(c[i]), c[i]});
        } 
        else
        {
            ll id=(*prev(s.end())).se;
            s.erase(prev(s.end()));
            pos[c[i]].pop_back();
            a[p[id]]=i, p[c[i]]=p[id], p[id]=-1;
            s.insert({get(c[i]), c[i]});
        }
    }
    for (ll i=n; i<n+k; i++)
    {
        for (ll j=0; j<cnt[i]; j++) WriteAdvice(1);
        WriteAdvice(0);
    }
    for (ll i=0; i<n; i++)
    {
        for (ll j=0; j<cnt[i]; j++) WriteAdvice(1);
        WriteAdvice(0);
    }
    return;
}
#include "assistant.h"
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

void Assist(unsigned char *a, int n, int k, int r) 
{
    ll ptr=0;
    vector <ll> ok, cnt(k, 0), p(n, -1);
    auto get=[&]() 
    {
        ll ans=0;
        while (a[ptr]==1) ans++, ptr++;
        ptr++; return ans;
    };
    for (ll i=0; i<k; i++)
    {
        cnt[i]=get(), p[i]=i;
        if (!cnt[i]) ok.pb(i);
    }
    for (ll i=0; i<n; i++)
    {
        ll cr=GetRequest();
        if (p[cr]!=-1) 
        {
            cnt[cr]--;
            if (!cnt[cr]) ok.pb(cr);
        }
        else
        {
            ll id=ok.back(); ok.pop_back();
            PutBack(id), p[cr]=id, cnt[cr]=get();
            if (!cnt[cr]) ok.pb(cr);
        }
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 788 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1904 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 Runtime error 65 ms 11176 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1072 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 Runtime error 83 ms 13552 KB Execution killed with signal 11
2 Runtime error 82 ms 13424 KB Execution killed with signal 11
3 Runtime error 83 ms 13936 KB Execution killed with signal 11
4 Runtime error 94 ms 13948 KB Execution killed with signal 11
5 Runtime error 84 ms 14228 KB Execution killed with signal 11
6 Runtime error 82 ms 13788 KB Execution killed with signal 11
7 Runtime error 81 ms 13944 KB Execution killed with signal 11
8 Runtime error 81 ms 13932 KB Execution killed with signal 11
9 Runtime error 92 ms 14788 KB Execution killed with signal 11
10 Runtime error 66 ms 14380 KB Execution killed with signal 11