Submission #1106299

# Submission time Handle Problem Language Result Execution time Memory
1106299 2024-10-29T19:02:14 Z jerzyk Message (IOI24_message) C++17
0 / 100
170 ms 860 KB
#include <bits/stdc++.h>
#include "message.h"

using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const int N = 1000 * 1000 + 7;
int xddd[40];
int jp[40];
vector<bool> M;
int il = 0, cnt = 0;

bool Nxt()
{
    if(cnt > (int)M.size()) return 0;
    return M[cnt++];
}

void send_message(vector<bool> _M, vector<bool> C)
{
    il = 0; cnt = 0;
    
    _M.pb(1);
    M = _M;
    vector<int> pos, dis;
    vector<bool> bas(31, false);
    vector<vector<bool>> answer(100, bas);

    for(int i = 0; i < (int)C.size(); ++i)
        if(C[i] == 0)
            pos.pb(i);
    for(int i = 0; i < 16; ++i)
    {
        int d;
        if(i < 15)
            d = pos[i + 1] - pos[i];
        else
            d = 31 + pos[0] - pos[i];
        dis.pb(d);
        answer[d - 1][pos[i]] = true;
        il = max(il, d);
    }
    for(int l = 0; cnt < (int)M.size(); ++l)
    {
        il = max(il, l);
        for(int i = 0; i < 16; ++i)
            if(dis[i] < l + 1)
                answer[l][pos[i]] = Nxt();
    }
    while((int)answer.size() > il + 1)
        answer.pop_back();
    for(int i = 0; i < (int)answer.size(); ++i)
        send_packet(answer[i]);
}

vector<bool> receive_message(vector<vector<bool>> R)
{
    il = 0; cnt = 0;
    vector<int> pos, dis;
    vector<bool> ans;
    for(int i = 0; i < 31; ++i)
    {
        int d = 1, l = 0;
        while(l < (int)R.size() && R[l][i] != 1)
            {++l; ++d;}
        xddd[i] = d;
        jp[i] = (i + d) % 31;
    }
    for(int i = 0; i < 31; ++i)
    {
        int d = 1, v = jp[i];
        while(v != i && d < 17)
        {
            ++d;
            v = jp[v];
        }
        if(d == 16)
        {
            dis.pb(xddd[i]);
            pos.pb(i);
        }
    }
    for(int l = 0; l < (int)R.size(); ++l)
        for(int i = 0; i < (int)pos.size(); ++i)
            if(dis[i] < l + 1)
                ans.pb(R[l][pos[i]]);
    while(ans.back() == 0)
        ans.pop_back();
    ans.pop_back();
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 656 KB Used 17 days
# Verdict Execution time Memory Grader output
1 Correct 170 ms 860 KB Used 10 days
2 Incorrect 162 ms 428 KB decoded message is incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 656 KB Used 17 days
2 Correct 170 ms 860 KB Used 10 days
3 Incorrect 162 ms 428 KB decoded message is incorrect
4 Halted 0 ms 0 KB -