Submission #561556

# Submission time Handle Problem Language Result Execution time Memory
561556 2022-05-13T06:27:12 Z amunduzbaev Broken Device (JOI17_broken_device) C++17
49 / 100
37 ms 2688 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;
	int bit = -1;
	for(int i=1;i<n;i++){
		if(!used[i] && !used[i-1]){
			used[i] = used[i-1] = 1;
			bit = i; break;
		}
	}
	
	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<=2;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);
	Set(bit - 1, 1), Set(bit, (b > 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;
	for(int i=0;i<n;i++){
		if(!a[i]) continue;
		if(a[i]){
			b += a[i + 1];
			l = i + 2;
			break;
		}
	}
	if(l == -1) return 0ll;
	
	//~ assert(~l);
	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 31 ms 2564 KB Output is partially correct - L* = 27
2 Partially correct 31 ms 2320 KB Output is partially correct - L* = 27
3 Partially correct 31 ms 2452 KB Output is partially correct - L* = 26
4 Partially correct 31 ms 2372 KB Output is partially correct - L* = 28
5 Partially correct 30 ms 2508 KB Output is partially correct - L* = 24
6 Partially correct 28 ms 2460 KB Output is partially correct - L* = 28
7 Partially correct 28 ms 2368 KB Output is partially correct - L* = 21
8 Partially correct 32 ms 2536 KB Output is partially correct - L* = 27
9 Partially correct 28 ms 2492 KB Output is partially correct - L* = 19
10 Partially correct 30 ms 2452 KB Output is partially correct - L* = 27
11 Partially correct 32 ms 2472 KB Output is partially correct - L* = 25
12 Partially correct 35 ms 2444 KB Output is partially correct - L* = 22
13 Partially correct 30 ms 2476 KB Output is partially correct - L* = 27
14 Partially correct 31 ms 2456 KB Output is partially correct - L* = 22
15 Partially correct 30 ms 2444 KB Output is partially correct - L* = 28
16 Partially correct 31 ms 2540 KB Output is partially correct - L* = 27
17 Partially correct 30 ms 2448 KB Output is partially correct - L* = 28
18 Partially correct 30 ms 2416 KB Output is partially correct - L* = 28
19 Partially correct 31 ms 2440 KB Output is partially correct - L* = 19
20 Partially correct 31 ms 2688 KB Output is partially correct - L* = 28
21 Partially correct 37 ms 2420 KB Output is partially correct - L* = 28
22 Partially correct 30 ms 2504 KB Output is partially correct - L* = 27
23 Partially correct 32 ms 2432 KB Output is partially correct - L* = 23
24 Partially correct 31 ms 2484 KB Output is partially correct - L* = 27
25 Partially correct 32 ms 2436 KB Output is partially correct - L* = 25
26 Partially correct 30 ms 2432 KB Output is partially correct - L* = 20
27 Partially correct 28 ms 2436 KB Output is partially correct - L* = 23
28 Partially correct 35 ms 2608 KB Output is partially correct - L* = 28
29 Partially correct 30 ms 2508 KB Output is partially correct - L* = 21
30 Partially correct 30 ms 2460 KB Output is partially correct - L* = 28
31 Partially correct 30 ms 2428 KB Output is partially correct - L* = 20
32 Partially correct 31 ms 2420 KB Output is partially correct - L* = 29
33 Partially correct 32 ms 2552 KB Output is partially correct - L* = 28
34 Partially correct 30 ms 2448 KB Output is partially correct - L* = 28
35 Partially correct 30 ms 2376 KB Output is partially correct - L* = 27
36 Partially correct 30 ms 2460 KB Output is partially correct - L* = 27
37 Partially correct 30 ms 2464 KB Output is partially correct - L* = 28
38 Partially correct 28 ms 2496 KB Output is partially correct - L* = 28
39 Partially correct 30 ms 2428 KB Output is partially correct - L* = 19
40 Partially correct 30 ms 2436 KB Output is partially correct - L* = 27