Submission #902902

# Submission time Handle Problem Language Result Execution time Memory
902902 2024-01-11T04:33:27 Z heavylightdecomp Parrots (IOI11_parrots) C++14
52 / 100
93 ms 1504 KB
#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define vt vector
#define pb push_back
#define X first
#define Y second
using pii = pair<int,int>;
#define debug(x) do\
{auto _x=x; cerr<<#x<<" = "<<_x<<'\n';}while(0);
#define f0r(i,a,b) for(auto i=(a);i<(b);i++)
#define r0f(i,a,b) for(auto i=(a);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
//There was a bug: position collisions
//Instead:
//First 5 bits for position (guaranteed distinct)
//Next bit for head/tail
//Next 2 bits for block
//remaining 2 bits in the times
void mysend(int a, int times) {
    debug(bitset<8>(a));
    debug(bitset<3>(times));
    f0r(i,0,times) send(a);
}
void encode(int N, int M[]) {
    f0r(pos,0,N) {
        debug(pos)
        //BUG: swapped around heads and tails order
        int body = pos << 3;
        int ha = M[pos] & ((1 << 2) - 1);
        int hb = (M[pos] >> 2) & ((1<<2)-1);
        int ta = (M[pos] >> 4) & ((1<<2)-1);
        int tb = (M[pos] >> 6) & ((1<<2)-1);
        //BUG: added twice
        mysend(body | ha, hb+1);
        mysend(body | (1 << 2) | ta, tb+1);
    }
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define vt vector
#define pb push_back
#define X first
#define Y second
using pii = pair<int,int>;
#define debug(x) do\
{auto _x=x; cerr<<#x<<" = "<<_x<<'\n';}while(0);
#define f0r(i,a,b) for(auto i=(a);i<(b);i++)
#define r0f(i,a,b) for(auto i=(a);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
//potential bug: confusion between N and L
void decode(int d_sz, int N, int xs[]) {
    vt<int> freq (255);
    vt<int> ans (d_sz);
    f0r(i,0,N) {
        freq[xs[i]]++;
    }
    f0r(a,0,255) if(freq[a]) { //BUG : need to check if 0 times
        int b_block = freq[a] - 1;
        int a_block = a & ((1<<2)-1);
        bool is_heads = !!(a & (1 << 2));
        int pos = a >> 3;
        debug(pos)
        debug(is_heads);
        debug(bitset<2>(b_block))
        debug(bitset<2>(a_block))
        //BUG: |=
        ans[pos] |= ((b_block << 2) | a_block) << (is_heads ? 4 : 0);
    }
    debug("I THINK....")
    f0r(i,0,d_sz) {
        cerr << ans[i] << ' ';
        output(ans[i]);
    }
    cerr << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1296 KB Output is correct
2 Correct 34 ms 1396 KB Output is correct
3 Correct 47 ms 1380 KB Output is correct
4 Correct 50 ms 1292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1304 KB Output is correct
2 Correct 38 ms 1504 KB Output is correct
3 Correct 49 ms 1208 KB Output is correct
4 Correct 55 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1304 KB Output is correct
2 Correct 59 ms 1296 KB Output is correct
3 Correct 80 ms 1464 KB Output is correct
4 Correct 89 ms 1488 KB Output is correct
5 Correct 93 ms 1400 KB Output is correct
6 Incorrect 40 ms 1344 KB Error : Output is wrong
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 49 ms 1292 KB Output is partially correct - P = 8.000000
2 Incorrect 40 ms 1408 KB Error : Output is wrong
3 Incorrect 1 ms 1292 KB Error : Bad encoded integer
4 Incorrect 1 ms 804 KB Error : Bad encoded integer
5 Incorrect 1 ms 780 KB Error : Bad encoded integer
6 Incorrect 1 ms 784 KB Error : Bad encoded integer
7 Incorrect 1 ms 784 KB Error : Bad encoded integer