답안 #562945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
562945 2022-05-15T16:39:11 Z amunduzbaev Broken Device (JOI17_broken_device) C++17
100 / 100
43 ms 2604 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 2504 KB Output is correct - L* = 40
2 Correct 33 ms 2544 KB Output is correct - L* = 40
3 Correct 33 ms 2460 KB Output is correct - L* = 40
4 Correct 31 ms 2416 KB Output is correct - L* = 40
5 Correct 33 ms 2568 KB Output is correct - L* = 40
6 Correct 41 ms 2500 KB Output is correct - L* = 40
7 Correct 43 ms 2516 KB Output is correct - L* = 40
8 Correct 31 ms 2512 KB Output is correct - L* = 40
9 Correct 31 ms 2600 KB Output is correct - L* = 40
10 Correct 31 ms 2476 KB Output is correct - L* = 40
11 Correct 34 ms 2484 KB Output is correct - L* = 40
12 Correct 36 ms 2560 KB Output is correct - L* = 40
13 Correct 30 ms 2508 KB Output is correct - L* = 40
14 Correct 31 ms 2484 KB Output is correct - L* = 40
15 Correct 37 ms 2504 KB Output is correct - L* = 40
16 Correct 30 ms 2500 KB Output is correct - L* = 40
17 Correct 33 ms 2572 KB Output is correct - L* = 40
18 Correct 33 ms 2508 KB Output is correct - L* = 40
19 Correct 33 ms 2516 KB Output is correct - L* = 40
20 Correct 32 ms 2468 KB Output is correct - L* = 40
21 Correct 33 ms 2564 KB Output is correct - L* = 40
22 Correct 37 ms 2468 KB Output is correct - L* = 40
23 Correct 32 ms 2432 KB Output is correct - L* = 40
24 Correct 31 ms 2544 KB Output is correct - L* = 40
25 Correct 32 ms 2548 KB Output is correct - L* = 40
26 Correct 31 ms 2504 KB Output is correct - L* = 40
27 Correct 33 ms 2580 KB Output is correct - L* = 40
28 Correct 32 ms 2412 KB Output is correct - L* = 40
29 Correct 34 ms 2484 KB Output is correct - L* = 40
30 Correct 31 ms 2504 KB Output is correct - L* = 40
31 Correct 33 ms 2564 KB Output is correct - L* = 40
32 Correct 36 ms 2564 KB Output is correct - L* = 40
33 Correct 37 ms 2568 KB Output is correct - L* = 40
34 Correct 30 ms 2588 KB Output is correct - L* = 40
35 Correct 31 ms 2532 KB Output is correct - L* = 40
36 Correct 43 ms 2604 KB Output is correct - L* = 40
37 Correct 31 ms 2580 KB Output is correct - L* = 40
38 Correct 31 ms 2496 KB Output is correct - L* = 40
39 Correct 32 ms 2536 KB Output is correct - L* = 40
40 Correct 38 ms 2604 KB Output is correct - L* = 40