Submission #7617

# Submission time Handle Problem Language Result Execution time Memory
7617 2014-08-13T04:25:47 Z baneling100 Last supper (IOI12_supper) C++
0 / 100
107 ms 7648 KB
#include "advisor.h"
#include <algorithm>
#include <queue>
#define INF 0x7fffffff

using namespace std;

typedef pair <int,int> ppair;
typedef pair <int,ppair> pppair;
static priority_queue <pppair> Q;
static int Time[200000], Check[100000], Out[200000];

void ComputeAdvice(int *C, int N, int K, int M) {

    int i, Temp1, Temp2;

    for(i=0 ; i<N ; i++)
        Check[i]=INF;
    for(i=N-1 ; i>=0 ; i--) {
        Time[K+i]=Check[C[i]];
        Check[C[i]]=K+i;
    }
    for(i=K-1 ; i>=0 ; i--)
        Time[i]=Check[i];
    for(i=0 ; i<N ; i++)
        Check[i]=0;
    for(i=0 ; i<K ; i++) {
        Q.push(make_pair(Time[i],make_pair(i,i)));
        Check[i]=1;
    }
    for(i=0 ; i<N ; i++)
        if(!Check[C[i]]) {
            Check[C[i]]=1;
            Temp1=Q.top().second.first;
            Temp2=Q.top().second.second;
            Q.pop();
            Check[Temp1]=0;
            Out[Temp2]=1;
            Q.push(make_pair(Time[K+i],make_pair(C[i],K+i)));
        }
    for(i=0 ; i<N+K ; i++)
        WriteAdvice(Out[i]);
}
#include "assistant.h"
#include <algorithm>
#include <queue>

using namespace std;

typedef pair <int,int> ppair;
static priority_queue <ppair> Q;
static int Check[100000];

void Assist(unsigned char *A, int N, int K, int R) {

    int i, Temp1, Temp2;

    for(i=0 ; i<K ; i++) {
        Q.push(make_pair(A[i],i));
        Check[i]=1;
    }
    for(i=0 ; i<N ; i++)
    {
        Temp1=GetRequest();
        if(!Check[Temp1]) {
            Check[Temp1]=1;
            Temp2=Q.top().second;
            Q.pop();
            Check[Temp2]=0;
            PutBack(Temp2);
            Q.push(make_pair(A[K+i],Temp1));
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 864 KB Output is correct
2 Incorrect 4 ms 1256 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1600 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 6032 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 6032 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 7216 KB Output isn't correct - not an optimal way
2 Incorrect 89 ms 7616 KB Output isn't correct - not an optimal way
3 Incorrect 84 ms 7616 KB Output isn't correct - not an optimal way
4 Incorrect 107 ms 7616 KB Output isn't correct - not an optimal way
5 Incorrect 98 ms 7648 KB Output isn't correct - not an optimal way
6 Incorrect 99 ms 7648 KB Output isn't correct - not an optimal way
7 Incorrect 84 ms 7648 KB Output isn't correct - not an optimal way
8 Incorrect 88 ms 7648 KB Output isn't correct - not an optimal way
9 Incorrect 94 ms 7648 KB Output isn't correct - not an optimal way
10 Correct 90 ms 7648 KB Output is correct - 125000 bits used