# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
400916 | duality | Broken Device (JOI17_broken_device) | C++11 | 65 ms | 2540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |