Submission #45412

# Submission time Handle Problem Language Result Execution time Memory
45412 2018-04-13T08:48:24 Z smu201111192 Parrots (IOI11_parrots) C++17
0 / 100
13 ms 2464 KB
#include "encoder.h"
#include "encoderlib.h"

int min(int u,int v){ return u < v ? u : v; }
int cnt[4];
void encode(int N, int M[])
{
    int d = min(32,N);
    
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 8; j++){
            if(i + 32 < N){
                int bit1 = ((M[i] & (1<<j)) > 0);
                int bit2 = ((M[i+32] & (1<<j)) > 0);
                if(bit1 == 0 && bit2 == 0) cnt[0]++;
                if(bit1 == 1 && bit2 == 1) cnt[3]++;
            }
        }
    }
    int rev = (cnt[3] > cnt[0]);
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 8; j++){
            int bit1 = ((M[i] & (1<<j)) > 0);
            int bit2 = - 1;
            if(i + 32 < N) bit2 = ((M[i+32] & (1<<j)) > 0);
            if( bit1 == bit2 ){
                if(rev && bit1 == 0 && bit2 == 0){
                    send(i*8+j);
                    send(i*8+j);
                    send(i*8+j);
                }
                if(!rev&&bit1 == 1 && bit2 == 1){
                    send(i*8+j);
                    send(i*8+j);
                    send(i*8+j);
                }
            }
            else{
                if (bit1 == 1 && bit2 == -1){
                    send(i*8+j);
                }
                else if(bit1 == 1 && bit2 == 0){
                    send(i*8+j);
                }
                else if(bit1 == 0 && bit2 == 1){
                    send(i*8+j);send(i*8+j);
                }
                else if(bit1 == 0 && bit2 == -1){
                    if(rev){
                        send(i*8+j);
                        send(i*8+j);
                        send(i*8+j);
                    }
                }
            }
        }
    }
    if(rev) { send(255) ,send(255) , send(255), send(255); }
}
#include "decoder.h"
#include "decoderlib.h"
int cnt[256];
int ans[65];
void decode(int N, int L, int X[])
{
    for(int i = 0; i < L; i++){
        cnt[X[i]]++;
    }
    int rev = 0;
    if(cnt[255] >= 4){
        rev = 1; cnt[255] -= 4;
    }
    for(int i = 0; i < 256; i++){
        int piv = i / 8;
        int add = i % 8;
        if(cnt[i] == 0){
            if(rev)
            {
                ans[piv] |= (1<<add);
                ans[piv+32] |= (1<<add);
            }
        }
        else if(cnt[i] == 1 ){
            ans[piv] |= (1<<add);
        }
        else if(cnt[i] == 2){
            ans[piv+32] |= (1<<add);
        }
        else if(cnt[i] == 3){
            if(!rev) {
                ans[piv] |= (1<<add);
                ans[piv+32] |= (1<<add);
            }
        }
        
    }
    for(int i = 0; i < N; i++){
        output(ans[i]);
    }
}
 
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 752 KB Error : Output is wrong
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1960 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1960 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2040 KB Error : Output is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2072 KB Error : Output is wrong
2 Incorrect 6 ms 2072 KB Error : Output is wrong
3 Incorrect 4 ms 2072 KB Error : Encoded message too long
4 Incorrect 4 ms 2072 KB Error : Encoded message too long
5 Incorrect 13 ms 2344 KB Error : Output is wrong
6 Incorrect 12 ms 2464 KB Error : Output is wrong
7 Incorrect 10 ms 2464 KB Error : Output is wrong