CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:ISIMO66
Submission time:2016-10-07 23:57:38 +0300
Language:C++
Status:READY
Result:29
Feedback
groupverdictscore
#1ACCEPTED10
#2ACCEPTED19
#30
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.06 s2details
#31.20 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%ld", &j); 
                  ^
input/code.cpp:16:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%ld", &input);
                       ^

Code

#include <stdio.h>
#include <stdlib.h>

char * nextMember(char *, long *);

int main(){
	char * list = (char *)malloc(2 * sizeof(char));
	long input;
	long i = 1;
	list[0] = '0';
	list[1] = '\0';
	long j;
	scanf("%ld", &j); 
	char * outList = (char *)malloc( j * sizeof(char));
	for (long k = 0; k < j; k++){
		scanf("%ld", &input);
		start:
		if (input > i) {
			list = nextMember(list, &i);
			goto start;
		}
		outList[k] = list[input-1];
	}
	for (long k = 0; k < j; k++){
		printf("%c\n", outList[k]);
	}
	

	free(list);
	return 0;

	
}

char * nextMember(char * prev, long * i){
	
	prev = (char *)realloc(prev, (*i * 2 + 1) * sizeof(char));
	for (int j = 0; j < *i; j++){
		if (prev[j] == '0') {
			prev[j + *i] = '1';
		}
		else {
			prev[j + *i] = '0';
		}
	}
	prev[*i * 2] = '\0';
	*i = *i * 2;
	return prev;
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
100
62
9
12
73
...

correct output
1
1
1
0
1
...

user output
1
1
1
0
1
...

Test 2

Group: 2

Verdict: ACCEPTED

input
100000
565433
141881
120108
825392
...

correct output
1
1
0
0
1
...

user output
1
1
0
0
1
...

Test 3

Group: 3

Verdict:

input
100000
374768524402011755
937067109466254318
389256426086302899
932585725667010169
...

correct output
0
1
1
1
1
...

user output
(empty)