Submission #1188616

#TimeUsernameProblemLanguageResultExecution timeMemory
1188616SofiatpcBroken Device (JOI17_broken_device)C++20
65 / 100
27 ms1548 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; static int marc[155]; void Anna( int n, long long x, int k, int p[] ){ mt19937 mt(5); for(int i = 0; i < n; i++)marc[i] = 0; for(int i = 0; i < k; i++)marc[p[i]] = 1; long long po = 1; for(int i = 2; i < n; i+=3){ if(po > 1e18){ Set(i-2, 0); Set(i-1, 0); Set(i, 0); continue; } vector<int> v = {0,1,2,3}; shuffle(v.begin(), v.end(), mt); int val = ((x&po)>0) + ((( x&(po*2))>0)<<1); if(marc[i] == 0 && marc[i-1] == 0 && marc[i-2] == 1){ //x__ if(v[0] == val){ Set(i-2, 0); Set(i-1, 1); Set(i, 0); po*=4; }else if(x & po){ Set(i-2, 0); Set(i-1, 1); Set(i, 1); po*=2; }else{ Set(i-2, 0); Set(i-1, 0); Set(i, 1); po*=2; } } else if(marc[i] == 0 && marc[i-1] == 1 && marc[i-2] == 0){//_x_ if(v[1] == val){ Set(i-2, 1); Set(i-1, 0); Set(i, 1); po*=4; }else if(x & po){ Set(i-2, 1); Set(i-1, 0); Set(i, 0); po*=2; }else{ Set(i-2, 0); Set(i-1, 0); Set(i, 1); po*=2; } } else if(marc[i] == 1 && marc[i-1] == 0 && marc[i-2] == 0){//__x if(v[0] == val){ Set(i-2, 0); Set(i-1, 1); Set(i, 0); po*=4; }else if(x & po){ Set(i-2, 1); Set(i-1, 0); Set(i, 0); po*=2; }else{ Set(i-2, 1); Set(i-1, 1); Set(i, 0); po*=2; } }else if(marc[i] == 0 && marc[i-1] == 0 && marc[i-2] == 0){//___ if(v[0] == val){ Set(i-2, 0); Set(i-1, 1); Set(i, 0); po*=4; }else if(v[1] == val){ Set(i-2, 1); Set(i-1, 0); Set(i, 1); po*=4; }else if(v[2] == val){ Set(i-2, 1); Set(i-1, 1); Set(i, 1); po*=4; }else if(x & po){ Set(i-2, 1); Set(i-1, 0); Set(i, 0); po*=2; }else{ Set(i-2, 1); Set(i-1, 1); Set(i, 0); po*=2; } }else{ Set(i-2, 0); Set(i-1, 0); Set(i, 0); } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; long long Bruno( int n, int a[] ){ mt19937 mt(5); long long x = 0, p = 1; for(int i = 2; i < n; i+=3){ vector<int> v = {0,1,2,3}; shuffle(v.begin(), v.end(), mt); if(a[i-2] == 0 && a[i-1] == 0 && a[i] == 1){ p*=2; }else if(a[i-2] == 0 && a[i-1] == 1 && a[i] == 1){ x += p; p*=2; }else if(a[i-2] == 1 && a[i-1] == 0 && a[i] == 0){ x += p; p*=2; }else if(a[i-2] == 1 && a[i-1] == 1 && a[i] == 0){ p*=2; }else if(a[i-2] == 0 && a[i-1] == 1 && a[i] == 0){ x += v[0]*p; p*=4; }else if(a[i-2] == 1 && a[i-1] == 0 && a[i] == 1){ x += v[1]*p; p*=4; }else if(a[i-2] == 1 && a[i-1] == 1 && a[i] == 1){ x += v[2]*p; p*=4; } } return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...