Submission #823833

# Submission time Handle Problem Language Result Execution time Memory
823833 2023-08-13T08:04:38 Z Amylopectin Flight to the Ford (BOI22_communication) C++17
0 / 100
44 ms 1692 KB
#include"communication.h"
#include <stdio.h>
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <time.h>
using namespace std;
const int mxn = 510,lo = 2,see = 7634530;
int dran[mxn] = {};
void encode(int n, int x) 
{
    int i,j,cn,cm,fn,fm,cou = 0,cret,csta;
    srand(see);
    for(i=0; i<410; i++)
    {
        if(rand() %20 == 2)
        {
            dran[i] = 1;
        }
        else 
        {
            dran[i] = 0;
        }
    }
    for(i=0; i<lo; i++)
    {
        if((1<<i) & x)
        {
            cn = 1;
        }
        else 
        {
            cn = 0;
        }
        // cm = (cn + dran[cou]) & 1;

        cou ++;
        cret = send(cn);
        if(cret == cn)
        {
            csta = 0;
        }
        else 
        {
            csta = 1;
        }
        while(1)
        {
            // cm = (cn + dran[cou]) & 1;
            if(dran[cou] == 0)
            {
                cou ++;
                cret = send(cn);
                if(csta == 0)
                {
                    if(cret == cn)
                    {
                        break;
                    }
                }
                csta = (csta + 1) & 1;
            }
            else 
            {
                cou ++;
                cm = (cret + 1) & 1;
                cret = send(cm);
                if(cret != cm)
                {
                    break;
                }
                cou ++;
                cret = send(cn);
                if(cret == cn)
                {
                    csta = 0;
                }
                else 
                {
                    csta = 1;
                }
            }
            if(cou > 230)
            {
                dran[29989923] ++;
            }
        }
    }
    return ;
}

std::pair<int, int> decode(int n) 
{
    int i,j,m,cn,cm,fn,fm,cva = 0,be,cou = 0;
    srand(see);
    for(i=0; i<410; i++)
    {
        if(rand() %20 == 2)
        {
            dran[i] = 1;
        }
        else 
        {
            dran[i] = 0;
        }
    }
    for(i=0; i<lo; i++)
    {
        be = receive();
        cou ++;
        while(1)
        {
            cn = receive();
            if(cn == be)
            {
                cva += (cn<<i);
                cou ++;
                break;
            }
            be = cn;
            if(dran[cou] == 1)
            {
                be = receive();
                cou ++;
            }
            cou ++;
        }
    }
    return {cva,1};
}

Compilation message

communication.cpp: In function 'void encode(int, int)':
communication.cpp:12:11: warning: unused variable 'j' [-Wunused-variable]
   12 |     int i,j,cn,cm,fn,fm,cou = 0,cret,csta;
      |           ^
communication.cpp:12:19: warning: unused variable 'fn' [-Wunused-variable]
   12 |     int i,j,cn,cm,fn,fm,cou = 0,cret,csta;
      |                   ^~
communication.cpp:12:22: warning: unused variable 'fm' [-Wunused-variable]
   12 |     int i,j,cn,cm,fn,fm,cou = 0,cret,csta;
      |                      ^~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:94:11: warning: unused variable 'j' [-Wunused-variable]
   94 |     int i,j,m,cn,cm,fn,fm,cva = 0,be,cou = 0;
      |           ^
communication.cpp:94:13: warning: unused variable 'm' [-Wunused-variable]
   94 |     int i,j,m,cn,cm,fn,fm,cva = 0,be,cou = 0;
      |             ^
communication.cpp:94:18: warning: unused variable 'cm' [-Wunused-variable]
   94 |     int i,j,m,cn,cm,fn,fm,cva = 0,be,cou = 0;
      |                  ^~
communication.cpp:94:21: warning: unused variable 'fn' [-Wunused-variable]
   94 |     int i,j,m,cn,cm,fn,fm,cva = 0,be,cou = 0;
      |                     ^~
communication.cpp:94:24: warning: unused variable 'fm' [-Wunused-variable]
   94 |     int i,j,m,cn,cm,fn,fm,cva = 0,be,cou = 0;
      |                        ^~
communication.cpp: In function 'void encode(int, int)':
communication.cpp:85:30: warning: array subscript 29989923 is above array bounds of 'int [510]' [-Warray-bounds]
   85 |                 dran[29989923] ++;
      |                 ~~~~~~~~~~~~~^
communication.cpp:9:5: note: while referencing 'dran'
    9 | int dran[mxn] = {};
      |     ^~~~
communication.cpp:85:30: warning: array subscript 29989923 is above array bounds of 'int [510]' [-Warray-bounds]
   85 |                 dran[29989923] ++;
      |                 ~~~~~~~~~~~~~^
communication.cpp:9:5: note: while referencing 'dran'
    9 | int dran[mxn] = {};
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1692 KB Output is correct
2 Runtime error 2 ms 424 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 236 KB Not correct
2 Halted 0 ms 0 KB -