Submission #55043

# Submission time Handle Problem Language Result Execution time Memory
55043 2018-07-05T22:14:18 Z spencercompton Broken Device (JOI17_broken_device) C++17
69 / 100
113 ms 3968 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string tostr(ll x){
	string ret = "";
	for(int i = 0; i<60; i++){
		if((x&(1LL<<i))!=0){
			ret += "1";
		}
		else{
			ret += "0";
		}
	}
	return ret;
}
void Anna( int N, long long X, int K, int P[] ){
	srand(42);
	vector<int>  rands;
	bool res[N];
	for(int i = 0; i<N; i++){
		res[i] = false;
	}
	for(int i = 0; i<1000; i++){
		rands.push_back(rand()%2);
	}
	for(int i = 0; i<K; i++){
		res[P[i]] = true;
	}
	string str = tostr(X);
	int pos = 0;
	int cur = 0;
	// if rands[i] = 0,    10 = 00, 11 = 01, 01 = 1
	for(int i = 0; i<N && pos<60; i+=2){
		if(res[i] || res[i+1]){
			continue;
		}
		cur++;
		if(pos==59){
			if(str[pos]=='0'){
				res[i] = false;
				res[i+1] = true;
			}
			else{
				res[i] = true;
				res[i+1] = true;
			}
			pos++;
			break;
		}
		if(str[pos]-'0'==rands[cur]){
			res[i] = true;
			if(str[pos+1]-'0'==rands[cur]){
				res[i+1] = true;
			}
			else{
				res[i+1] = false;
			}
			pos += 2;
		}
		else{
			res[i] = false;
			res[i+1] = true;
			pos++;
		}
	}
	for(int i = 0; i<N; i++){
		Set(i,res[i]?1:0);
	}

}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fromstr(string s){
	ll ret = 0LL;
	for(int i = 0; i<60; i++){
		if(s[i]=='1'){
			ret += (1LL<<i);
		}
	}
	return ret;
}
long long Bruno( int N, int A[] ){
	srand(42);
	vector<int>  rands;
	for(int i = 0; i<1000; i++){
		rands.push_back(rand()%2);
	}
	string str = "";
	int pos = 0;
	int cur = 0;
	// if rands[i] = 0,    10 = 00, 11 = 01, 01 = 1
	for(int i = 0; i<N && (int)str.length()<60; i+=2){
		if(A[i]==0 && A[i+1]==0){
			continue;
		}
		cur++;
		if((int)str.length()==59){
			if(A[i]==0){
				str += "0";
			}
			else{
				str += "1";
			}
			break;
		}
		if(A[i]==1){
			str += (char)(rands[cur]+'0');
			if(A[i+1]==1){
				str += (char)(rands[cur]+'0');
			}
			else{
				str += (char)((1-rands[cur])+'0');
			}
		}
		else{
			str += (char)((1-rands[cur])+'0');
		}
	}
	return fromstr(str);
}

Compilation message

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:21:6: warning: unused variable 'pos' [-Wunused-variable]
  int pos = 0;
      ^~~
# Verdict Execution time Memory Grader output
1 Partially correct 75 ms 2960 KB Output is partially correct - L* = 32
2 Partially correct 69 ms 3264 KB Output is partially correct - L* = 32
3 Partially correct 67 ms 3264 KB Output is partially correct - L* = 34
4 Partially correct 68 ms 3264 KB Output is partially correct - L* = 32
5 Partially correct 82 ms 3528 KB Output is partially correct - L* = 33
6 Partially correct 71 ms 3664 KB Output is partially correct - L* = 33
7 Partially correct 79 ms 3712 KB Output is partially correct - L* = 33
8 Partially correct 73 ms 3968 KB Output is partially correct - L* = 32
9 Partially correct 75 ms 3968 KB Output is partially correct - L* = 32
10 Partially correct 79 ms 3968 KB Output is partially correct - L* = 32
11 Partially correct 77 ms 3968 KB Output is partially correct - L* = 32
12 Partially correct 91 ms 3968 KB Output is partially correct - L* = 33
13 Partially correct 113 ms 3968 KB Output is partially correct - L* = 35
14 Partially correct 89 ms 3968 KB Output is partially correct - L* = 33
15 Partially correct 83 ms 3968 KB Output is partially correct - L* = 35
16 Partially correct 79 ms 3968 KB Output is partially correct - L* = 33
17 Partially correct 80 ms 3968 KB Output is partially correct - L* = 32
18 Partially correct 83 ms 3968 KB Output is partially correct - L* = 32
19 Partially correct 88 ms 3968 KB Output is partially correct - L* = 33
20 Partially correct 87 ms 3968 KB Output is partially correct - L* = 36
21 Partially correct 79 ms 3968 KB Output is partially correct - L* = 33
22 Partially correct 87 ms 3968 KB Output is partially correct - L* = 33
23 Partially correct 80 ms 3968 KB Output is partially correct - L* = 36
24 Partially correct 87 ms 3968 KB Output is partially correct - L* = 32
25 Partially correct 72 ms 3968 KB Output is partially correct - L* = 31
26 Partially correct 72 ms 3968 KB Output is partially correct - L* = 33
27 Partially correct 74 ms 3968 KB Output is partially correct - L* = 33
28 Partially correct 78 ms 3968 KB Output is partially correct - L* = 33
29 Partially correct 75 ms 3968 KB Output is partially correct - L* = 33
30 Partially correct 77 ms 3968 KB Output is partially correct - L* = 33
31 Partially correct 78 ms 3968 KB Output is partially correct - L* = 32
32 Partially correct 83 ms 3968 KB Output is partially correct - L* = 31
33 Partially correct 79 ms 3968 KB Output is partially correct - L* = 34
34 Partially correct 77 ms 3968 KB Output is partially correct - L* = 29
35 Partially correct 79 ms 3968 KB Output is partially correct - L* = 34
36 Partially correct 96 ms 3968 KB Output is partially correct - L* = 33
37 Partially correct 79 ms 3968 KB Output is partially correct - L* = 32
38 Partially correct 101 ms 3968 KB Output is partially correct - L* = 35
39 Partially correct 79 ms 3968 KB Output is partially correct - L* = 31
40 Partially correct 75 ms 3968 KB Output is partially correct - L* = 32