Submission #562945

#TimeUsernameProblemLanguageResultExecution timeMemory
562945amunduzbaevBroken Device (JOI17_broken_device)C++17
100 / 100
43 ms2604 KiB
#include "Annalib.h"
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

void Anna(int n, ll x, int k, int p[]){
	vector<int> cnt(n / 3), is(n), used(n);
	for(int i=0;i<k;i++){
		cnt[p[i] / 3]++;
		is[p[i]] = 1;
	}
	
	auto sett = [&](int i, int a, int b, int c){
		i *= 3;
		used[i] = a, used[i + 1] = b, used[i + 2] = c;
	};
	
	for(int i=0;i<n/3 && x;i++){
		if(cnt[i] > 1) continue;
		if(cnt[i] == 0){
			ll v = ((x & 1) << 1) | ((x >> 1) & 1);
			if(v == 0) sett(i, 1, 0, 1);
			if(v == 1) sett(i, 1, 1, 1);
			if(v == 2) sett(i, 1, 1, 0);
			if(v == 3) sett(i, 0, 1, 0);
			x >>= 2;
		} else {
			if(!(x & 1)){
				if(is[i * 3]) sett(i, 0, 1, 1);
				else sett(i, 1, 0, 0);
				x >>= 1;
			} else {
				if(is[i * 3] || is[i * 3 + 1]) sett(i, 0, 0, 1), x >>= 1;
				else{
					if((x >> 1) & 1) sett(i, 0, 1, 0);
					else sett(i, 1, 1, 0);
					x >>= 2;
				}
			}
		}
	}
	//~ for(int i=3;i<9;i++) cout<<used[i]<<" ";
	//~ cout<<"\n";
	for(int i=0;i<n;i++){
		Set(i, used[i]);
	}
}

/*

2
150 14 1
2
150 9 2
0 1

*/
#include "Brunolib.h"
#include "bits/stdc++.h"
using namespace std;

long long Bruno( int n, int a[] ){
	long long x = 0, j = 0;
	for(int i=0;i + 2<n;i+=3){
		int v = a[i] * 4 + a[i+1] * 2 + a[i+2];
		if(v == 0) continue;
		if(v == 1) x |= (1ll << j), j++;
		if(v == 2) x |= (1ll << j), j++, x |= (1ll << j), j++;
		if(v == 3) j++;
		if(v == 4) j++;
		if(v == 5) j++, j++;
		if(v == 6) x |= (1ll << j), j++, j++;
		if(v == 7) j++, x |= (1ll << j), j++;
	}
	
	//~ cout<<x<<"\n";
	return x;
}
#Verdict Execution timeMemoryGrader output
Fetching results...