Submission #605654

# Submission time Handle Problem Language Result Execution time Memory
605654 2022-07-25T21:18:22 Z duality Flight to the Ford (BOI22_communication) C++17
0 / 100
1086 ms 1784 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "communication.h"

vi secret = {10,20,13,23,21,10,12,10,32,30,30,23,2,10,21,30,30,13,31,30,30,23,10,13,13,32,23,13,30,13,3,23,2,3,2,23,23,21,23,10,10,2,3,21,31,1,20,13,23,10,10,30,1,10,12,10,2,23,12,12,23,12,32,31,31,20,13,20,32,30,10,12,10,10,12,20,20,10,3,21,21,3,1,30,21,32,20,1,1,2,12,13,21,3,32,2,2,30,21,13,10,30,3,32,23,2,3,10,31,12,30,21,1,23,3,21,10,13,1,20,21,21,21,31,1,23,1,3,21,32,12,1,12,23,10,12,3,32,3,31,12,12,31,20,20,2,12,3,12,10,1,1,13,20,10,12,23,30,31,31,13,20,10,13,20,2,30,20,2,21,13,13,3,3,12,13,20,13,3,13,32,10,3,1,10,21,12,23,21,3,32,21,20,13,23,21,3,10,31,21,10,31,3,21,13,20,30,31,32,12,30,10,10,2,21,2,32,10,20,32,32,3,13,3,30,31,2,20,32,23,32,23,31,1,1,21,21,3,30,1,20,13,10,13,10,32,20,32,13,32,2,20,20,30,32,13,21,2,2,21,2,20,10,12,20,31,10,10,13,10,1,12,12,30,31,2,31,3,23,20,12,12,3,10,12,10,30,10,31,3,12,2,20,10,3,32,31,30,32,32,20,12,32,10,21,13,20,30,10,10,2,2,23,12,12,30,21,31,3,3,2,2,32,20,13,3,10,2,13,12,20,12,31,3,32,1,2,31,31,1,12,13,30,13,10,10,31,13,1,1,20,31,30,20,30,3,13,21,20,12,1,30,32,20,21,30,31,23,2,32,10,10,23,13,32,10,12,10,23,12,2,2,23,12,32,3,30,1,30,31,12,13,3,3,12,21,23,12,23,2,3,30,12,12,2,32,13,1,21,31,32,13,3,3,30,21,2,21,12,1,20,30,13,3,23,2,2,21,30,23,13,13,23,20,12,1,3,12,32,30,1,13,13,3,20,21,12,31,32,23,12,23,23,21,31,23,3,30,13,3,10,23,20,10,12,2,31,30,12,23,32,12,30,23,3,20,13,1,2,31,32,21,10,12,1,12,13,30,3,23,31,23,13,12,3,3,23,13,21,1};
void encode(int N,int X) {
    int i,c = 0,m = 0;
    for (i = 0; i < 30; i++) {
        int b = (X >> i) & 1;
        if (m) send(b),m = 0;
        else {
            while (1) {
                int b1,b2;
                if (b == 0) b1 = send((secret[c]/10) >> 1),b2 = send((secret[c]/10) & 1);
                else b1 = send((secret[c] % 10) >> 1),b2 = send((secret[c] % 10) & 1);
                if ((((secret[c]/10)^(secret[c] % 10)) == 2) && (b2 != ((secret[c]/10) & 1))) m = 1;
                if ((b == 0) && ((secret[c] % 10) == ((2*b1+b2)^3))) {
                    c++;
                    break;
                }
                else if ((b == 1) && ((secret[c]/10) == ((2*b1+b2)^3))) {
                    c++;
                    break;
                }
                c++;
                if (m) {
                    send(b),m = 0;
                    break;
                }
            }
        }
    }
}
pair<int,int> decode(int N) {
    int i,X = 0,c = 0,m = 0;
    for (i = 0; i < 30; i++) {
        if (m) X |= (receive() << i),m = 0;
        else {
            while (1) {
                int b1 = receive(),b2 = receive();
                if ((((secret[c]/10)^(secret[c] % 10)) == 2) && (b2 != ((secret[c]/10) & 1))) m = 1;
                if ((secret[c]/10) == ((2*b1+b2)^3)) {
                    X |= (1 << i),c++;
                    break;
                }
                else if ((secret[c] % 10) == ((2*b1+b2)^3)) {
                    c++;
                    break;
                }
                c++;
                if (m) {
                    X |= (receive() << i),m = 0;
                    break;
                }
            }
        }
    }
    return mp(X,X);
}
# Verdict Execution time Memory Grader output
1 Correct 101 ms 1784 KB Output is correct
2 Correct 158 ms 1688 KB Output is correct
3 Correct 238 ms 1736 KB Output is correct
4 Correct 124 ms 1688 KB Output is correct
5 Incorrect 6 ms 236 KB Not correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1086 ms 1756 KB Output is partially correct
2 Partially correct 510 ms 1728 KB Output is partially correct
3 Partially correct 662 ms 1688 KB Output is partially correct
4 Incorrect 450 ms 200 KB Not correct
5 Halted 0 ms 0 KB -