Submission #400916

# Submission time Handle Problem Language Result Execution time Memory
400916 2021-05-08T20:11:54 Z duality Broken Device (JOI17_broken_device) C++11
100 / 100
65 ms 2540 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 "Annalib.h"

LLI y = 183465712312354678LL;
int bad[150],Q[150];
void Anna(int N,long long int X,int K,int P[]) {
    X ^= y;
    int i,c = 0;
    for (i = 0; i < N; i++) Q[i] = i,bad[i] = 0;
    for (i = 0; i < N; i++) swap(Q[i],Q[y % (i+1)]);
    for (i = 0; i < K; i++) bad[P[i]] = 1;
    for (i = 0; i < N; i += 3) {
        int t = 0,o = 0,o2 = 0;
        if (((X >> c) & 3) == 0) t = 5;
        else if (((X >> c) & 3) == 1) t = 7;
        else if (((X >> c) & 3) == 2) t = 3;
        else t = 6;
        if ((X >> c) & 1) o = o2 = 1;
        else o = 2,o2 = 4;
        if (!((t & 1) && bad[Q[i]]) && !((t & 2) && bad[Q[i+1]]) && !((t & 4) && bad[Q[i+2]])) {
            Set(Q[i],t & 1);
            Set(Q[i+1],(t >> 1) & 1);
            Set(Q[i+2],(t >> 2) & 1);
            c += 2;
        }
        else if (bad[Q[i]]+bad[Q[i+1]]+bad[Q[i+2]] >= 2) Set(Q[i],0),Set(Q[i+1],0),Set(Q[i+2],0);
        else if (!((o & 1) && bad[Q[i]]) && !((o & 2) && bad[Q[i+1]]) && !((o & 4) && bad[Q[i+2]])) {
            Set(Q[i],o & 1);
            Set(Q[i+1],(o >> 1) & 1);
            Set(Q[i+2],(o >> 2) & 1);
            c++;
        }
        else if (!((o2 & 1) && bad[Q[i]]) && !((o2 & 2) && bad[Q[i+1]]) && !((o2 & 4) && bad[Q[i+2]])) {
            Set(Q[i],o2 & 1);
            Set(Q[i+1],(o2 >> 1) & 1);
            Set(Q[i+2],(o2 >> 2) & 1);
            c++;
        }
        else {
            Set(Q[i],0);
            Set(Q[i+1],0);
            Set(Q[i+2],1);
            c++;
        }
    }
}
#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 "Brunolib.h"

LLI yy = 183465712312354678LL;
int QQ[150];
long long int Bruno(int N,int A[]) {
    int i,c = 0;
    LLI X = 0;
    vi pos;
    for (i = 0; i < N; i++) QQ[i] = i;
    for (i = 0; i < N; i++) swap(QQ[i],QQ[yy % (i+1)]);
    for (i = 0; i < N; i += 3) {
        int b = A[QQ[i]] | (A[QQ[i+1]] << 1) | (A[QQ[i+2]] << 2);
        if (b == 6) X |= (3LL << c),c += 2;
        else if (b == 3) X |= (2LL << c),c += 2;
        else if (b == 7) X |= (1LL << c),c += 2;
        else if (b == 5) c += 2;
        else if (b == 4) pos.pb(c),c++;
        else if (b == 2) c++;
        else if (b == 1) X |= (1LL << c),c++;
        if (c > 60) break;
    }
    for (i = pos.size()-1; i >= 0; i--) {
        X &= ~(1LL << pos[i]);
        if (!(X & (1LL << (pos[i]+1)))) X |= (1LL << pos[i]);
    }
    X ^= yy;
    return X;
}

# Verdict Execution time Memory Grader output
1 Correct 51 ms 2364 KB Output is correct - L* = 40
2 Correct 47 ms 2540 KB Output is correct - L* = 40
3 Correct 48 ms 2260 KB Output is correct - L* = 40
4 Correct 51 ms 2280 KB Output is correct - L* = 40
5 Correct 46 ms 2216 KB Output is correct - L* = 40
6 Correct 48 ms 2344 KB Output is correct - L* = 40
7 Correct 49 ms 2328 KB Output is correct - L* = 40
8 Correct 47 ms 2200 KB Output is correct - L* = 40
9 Correct 48 ms 2280 KB Output is correct - L* = 40
10 Correct 50 ms 2332 KB Output is correct - L* = 40
11 Correct 47 ms 2296 KB Output is correct - L* = 40
12 Correct 49 ms 2140 KB Output is correct - L* = 40
13 Correct 48 ms 2324 KB Output is correct - L* = 40
14 Correct 50 ms 2292 KB Output is correct - L* = 40
15 Correct 53 ms 2404 KB Output is correct - L* = 40
16 Correct 47 ms 2240 KB Output is correct - L* = 40
17 Correct 50 ms 2236 KB Output is correct - L* = 40
18 Correct 51 ms 2308 KB Output is correct - L* = 40
19 Correct 46 ms 2316 KB Output is correct - L* = 40
20 Correct 47 ms 2312 KB Output is correct - L* = 40
21 Correct 65 ms 2480 KB Output is correct - L* = 40
22 Correct 57 ms 2240 KB Output is correct - L* = 40
23 Correct 49 ms 2144 KB Output is correct - L* = 40
24 Correct 46 ms 2268 KB Output is correct - L* = 40
25 Correct 48 ms 2264 KB Output is correct - L* = 40
26 Correct 58 ms 2268 KB Output is correct - L* = 40
27 Correct 46 ms 2420 KB Output is correct - L* = 40
28 Correct 46 ms 2308 KB Output is correct - L* = 40
29 Correct 50 ms 2160 KB Output is correct - L* = 40
30 Correct 46 ms 2292 KB Output is correct - L* = 40
31 Correct 47 ms 2236 KB Output is correct - L* = 40
32 Correct 46 ms 2352 KB Output is correct - L* = 40
33 Correct 47 ms 2300 KB Output is correct - L* = 40
34 Correct 45 ms 2208 KB Output is correct - L* = 40
35 Correct 47 ms 2392 KB Output is correct - L* = 40
36 Correct 46 ms 2356 KB Output is correct - L* = 40
37 Correct 46 ms 2224 KB Output is correct - L* = 40
38 Correct 48 ms 2272 KB Output is correct - L* = 40
39 Correct 46 ms 2208 KB Output is correct - L* = 40
40 Correct 46 ms 2244 KB Output is correct - L* = 40