Submission #561574

# Submission time Handle Problem Language Result Execution time Memory
561574 2022-05-13T07:33:44 Z amunduzbaev Broken Device (JOI17_broken_device) C++17
61 / 100
50 ms 2656 KB
#include "Annalib.h"
#include "bits/stdc++.h"
using namespace std;

void Anna(int n, long long x, int k, int p[]){
	vector<int> used(n);
	for(int i=0;i<k;i++) used[p[i]] = 1;
	const int M = 2;
	vector<int> bit(M);
	int t = 0;
	for(int i=1;i<n && t < M;i++){
		if(!used[i] && !used[i-1]){
			used[i] = used[i-1] = 1;
			bit[t++] = i;
		}
	}
	
	vector<int> pos;
	for(int i=0;i<n;){
		if(used[i]) { i++; continue; }
		int j = i;
		while(j < n && !used[j]) j++;
		pos.push_back(j - i);
		i = j;
	}
	int b = -1;
	for(int i=1;i<=(1 << M);i++){
		int cnt = 0;
		for(auto x : pos){
			cnt += (x / (i + 1));
		}
		
		if(cnt >= 60 / i){
			b = i;
		}
	}
	if(!(~b)){
		for(int i=0;i<n;i++) Set(i, 0);
		//~ assert(false);
		return;
	}
	
	for(int i=0;i<k;i++) Set(p[i], 0);
	int v = b - 1;
	for(int i=0;i<M;i++){
		Set(bit[i] - 1, 1);
		Set(bit[i], v & 1);
		v >>= 1;
	}
	int l = 0;
	for(int i=0;i<60;i+=b){
		while(l<n){
			int ok = 1;
			for(int k=0;k<=b;k++){
				if(l < k) ok = 0;
				else if(used[l - k]) ok = 0;
			}
			
			if(ok) break;
			l++;
		}
		
		//~ assert(l<n);
		for(int j=b - 1;~j;j--){
			Set(l - j, x & 1);
			used[l - j] = 1;
			x >>= 1;
		}
		
		used[l - b] = 1;
		Set(l - b, 1);
	}
	
	for(int i=0;i<n;i++){
		if(!used[i]){
			Set(i, 0);
		}
	}
}

/*

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[] ){
	int b = 1, l = -1;
	const int M = 2;
	int val = 0, t = 0;
	for(int i=0;i<n && t < M;i++){
		if(!a[i]) continue;
		if(a[i]){
			val |= (a[i + 1] << t);
			t++, i++, l = i + 1;
		}
	}
	if(l == -1) return 0ll;
	b = val + 1;
	int bit = 0;
	long long x = 0;
	for(int i=l;i<n;i++){
		if(a[i]){
			for(int j=i+1;j<=i+b && bit < 60;j++){
				x |= ((a[j] * 1ll) << bit);
				bit++;
			}
			
			i += b;
		}
	}
	
	//~ cout<<x<<endl;
	return x;
}
# Verdict Execution time Memory Grader output
1 Partially correct 36 ms 2540 KB Output is partially correct - L* = 26
2 Partially correct 44 ms 2496 KB Output is partially correct - L* = 26
3 Partially correct 37 ms 2452 KB Output is partially correct - L* = 26
4 Partially correct 36 ms 2552 KB Output is partially correct - L* = 25
5 Partially correct 37 ms 2508 KB Output is partially correct - L* = 25
6 Partially correct 36 ms 2532 KB Output is partially correct - L* = 25
7 Partially correct 44 ms 2484 KB Output is partially correct - L* = 26
8 Partially correct 34 ms 2512 KB Output is partially correct - L* = 25
9 Partially correct 40 ms 2520 KB Output is partially correct - L* = 26
10 Partially correct 41 ms 2592 KB Output is partially correct - L* = 25
11 Partially correct 35 ms 2564 KB Output is partially correct - L* = 26
12 Partially correct 41 ms 2484 KB Output is partially correct - L* = 25
13 Partially correct 47 ms 2540 KB Output is partially correct - L* = 25
14 Partially correct 50 ms 2500 KB Output is partially correct - L* = 26
15 Partially correct 36 ms 2456 KB Output is partially correct - L* = 25
16 Partially correct 43 ms 2448 KB Output is partially correct - L* = 25
17 Partially correct 44 ms 2480 KB Output is partially correct - L* = 26
18 Partially correct 37 ms 2484 KB Output is partially correct - L* = 25
19 Partially correct 34 ms 2568 KB Output is partially correct - L* = 27
20 Partially correct 39 ms 2572 KB Output is partially correct - L* = 25
21 Partially correct 34 ms 2464 KB Output is partially correct - L* = 26
22 Partially correct 34 ms 2456 KB Output is partially correct - L* = 27
23 Partially correct 37 ms 2492 KB Output is partially correct - L* = 25
24 Partially correct 39 ms 2632 KB Output is partially correct - L* = 25
25 Partially correct 41 ms 2544 KB Output is partially correct - L* = 26
26 Partially correct 38 ms 2456 KB Output is partially correct - L* = 25
27 Partially correct 44 ms 2456 KB Output is partially correct - L* = 26
28 Partially correct 36 ms 2476 KB Output is partially correct - L* = 26
29 Partially correct 46 ms 2588 KB Output is partially correct - L* = 26
30 Partially correct 48 ms 2540 KB Output is partially correct - L* = 25
31 Partially correct 43 ms 2512 KB Output is partially correct - L* = 26
32 Partially correct 43 ms 2544 KB Output is partially correct - L* = 26
33 Partially correct 50 ms 2516 KB Output is partially correct - L* = 26
34 Partially correct 40 ms 2388 KB Output is partially correct - L* = 25
35 Partially correct 45 ms 2556 KB Output is partially correct - L* = 26
36 Partially correct 39 ms 2656 KB Output is partially correct - L* = 26
37 Partially correct 36 ms 2484 KB Output is partially correct - L* = 25
38 Partially correct 39 ms 2608 KB Output is partially correct - L* = 26
39 Partially correct 36 ms 2516 KB Output is partially correct - L* = 25
40 Partially correct 45 ms 2576 KB Output is partially correct - L* = 26