Submission #1319763

#TimeUsernameProblemLanguageResultExecution timeMemory
1319763PlayVoltzBroken Device (JOI17_broken_device)C++20
8 / 100
20 ms1564 KiB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

void Anna(int n, long long x, int k, int p[]){
	vector<bool> die(n, 0), res(n, 0);
	for (int i=0; i<k; ++i)die[p[i]]=1;
	long long b=0;
	for (int i=0; i<n/3&&b<60; ++i){
		if (b==59){
			if ((1ll<<b)&x&&!die[i+2*n/3])res[i+2*n/3]=1, ++b;
			else if (!((1ll<<b)&x)&&!die[i])res[i]=1, ++b;
			break;
		}
		bool done=0;
		if (((1ll<<b)&x)&&((1ll<<(b+1))&x)){
			if (!die[i+n/3]&&!die[i+2*n/3])res[i+n/3]=res[i+2*n/3]=1, b+=2, done=1;
		}
		else if (!((1ll<<b)&x)&&!((1ll<<(b+1))&x)){
			if (!die[i+n/3]&&!die[i])res[i+n/3]=res[i]=1, b+=2, done=1;
		}
		else if (((1ll<<b)&x)&&!((1ll<<(b+1))&x)){
			if (!die[i]&&!die[i+2*n/3])res[i]=res[i+2*n/3]=1, b+=2, done=1;
		}
		else if (!((1ll<<b)&x)&&((1ll<<(b+1))&x)){
			if (!die[i+n/3])res[i+n/3]=1, b+=2, done=1;
		}
		if (!done){
			if ((1ll<<b)&x&&!die[i+2*n/3])res[i+2*n/3]=1, ++b;
			else if (!((1ll<<b)&x)&&!die[i])res[i]=1, ++b;
		}
	}
	for (int i=0; i<n; ++i)Set(i, res[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

long long Bruno(int n, int vect[]){
	long long res=0, b=0;
	for (int i=0; i<n/3&&b<60; ++i){
		if (!vect[i]&&!vect[i+n/3]&&!vect[i+2*n/3])continue;
		if (!vect[i]&&!vect[i+n/3]&&vect[i+2*n/3])res+=(1ll<<b), ++b;
		if (vect[i]&&!vect[i+n/3]&&!vect[i+2*n/3])++b;
		if (!vect[i]&&vect[i+n/3]&&!vect[i+2*n/3])res+=(1ll<<(b+1)), b+=2;
		if (!vect[i]&&vect[i+n/3]&&vect[i+2*n/3])res+=(1ll<<b)+(1ll<<(b+1)), b+=2;
		if (vect[i]&&!vect[i+n/3]&&vect[i+2*n/3])res+=(1ll<<b), b+=2;
		if (vect[i]&&vect[i+n/3]&&!vect[i+2*n/3])b+=2;
	}
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...