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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:13:16: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=]
  scanf("%d", &j); 
                ^
input/code.cpp:13:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &j); 
                 ^
input/code.cpp:16:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &input);
                      ^

Code

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

char * nextMember(char *, int *);

int main(){
	char * list = (char *)malloc(2 * sizeof(char));
	int input;
	int i = 1;
	list[0] = '0';
	list[1] = '\0';
	long j;
	scanf("%d", &j); 
	char * outList = (char *)malloc( j * sizeof(char));
	for (long k = 0; k < j; k++){
		scanf("%d", &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, int * 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)