Submission #718872

# Submission time Handle Problem Language Result Execution time Memory
718872 2023-04-05T04:14:50 Z lam Last supper (IOI12_supper) C++14
0 / 100
119 ms 13296 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
#define ff first
#define ss second
map<int,int> mp;
const int maxn = 2e5 + 10;
int n,k,m;
int a[maxn],pre[maxn],id[maxn],type[maxn];
int xoa[maxn];
void ComputeAdvice(int *C, int N, int K, int M) {
    n=N; k=K;
    for (int i=1; i<=k; i++) a[i]=i-1;
    for (int i=1; i<=n; i++) a[i+k] = C[i-1];
    mp.clear();
    m=n+k;
    for (int i=m; i>=1; i--)
    {
        if (!mp[a[i]]) pre[i]=n+1;
        else pre[i]=mp[a[i]];
        mp[a[i]]=i;
    }
    fill_n(id,m+1,0);
    priority_queue<ii,vector<ii>,less<ii>> pq;
    for (int i=1; i<=k; i++) pq.push({pre[i],i}),id[a[i]]=i;
    for (int i=k+1; i<=m; i++)
    {
        if (id[a[i]]!=0)
        {
            type[id[a[i]]] = 1;
            id[a[i]]=i;
            continue;
        }
        xoa[i] = pq.top().ss;
        pq.pop();
        pq.push({pre[i],i});
        type[xoa[i]] = 2;
        id[a[xoa[i]]] = 0;
        id[a[i]] = i;
    }
    for (int i=0; i<n; i++) if (id[i]!=0) type[id[i]] = 2;
    for (int i=1; i<=m; i++) if (type[i]==1) WriteAdvice(1);
    else WriteAdvice(0);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
typedef pair<int,int> ii;
#define ff first
#define ss second
int n,m,k;
int type[maxn];
void Assist(unsigned char *A, int N, int K, int R) {

    n=N;
    k=K;
    m=n+k;
    multiset<ii> ms;
    fill_n(type,m+1,0);
    for (int i=1; i<=k; i++)
    {
        char x = A[i-1];
        if (x=='1') type[i-1] = 2;
        else type[i-1] = 1;
        ms.insert({type[i-1],i-1});
    };
    for (int i=1; i<=n; i++)
    {
        int x=GetRequest();
        char c = A[k+i-1];
        if (type[x]!=0)
        {
            ms.erase(ms.find({type[x],x}));
            type[x] = (c=='1')+1;
            ms.insert({type[x],x});
        }
        else
        {
            auto r = ms.end(); r--;
            PutBack(r->ss);
            type[r->ss] = 0;
            ms.erase(r);
            type[x] = (c=='1')+1;
            ms.insert({type[x],x});
        }
    }

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 524 KB Output is correct
2 Incorrect 1 ms 648 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1648 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 9720 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1056 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 112 ms 11608 KB Output isn't correct - not an optimal way
2 Incorrect 114 ms 11852 KB Output isn't correct - not an optimal way
3 Incorrect 111 ms 12000 KB Output isn't correct - not an optimal way
4 Incorrect 119 ms 12036 KB Output isn't correct - not an optimal way
5 Incorrect 110 ms 12004 KB Output isn't correct - not an optimal way
6 Incorrect 113 ms 12180 KB Output isn't correct - not an optimal way
7 Incorrect 114 ms 12012 KB Output isn't correct - not an optimal way
8 Incorrect 110 ms 12016 KB Output isn't correct - not an optimal way
9 Incorrect 111 ms 12044 KB Output isn't correct - not an optimal way
10 Incorrect 113 ms 13296 KB Output isn't correct - not an optimal way