CSES - Datatähti 2022 alku - Results
Submission details
Task:Merkkijono
Sender:victor05
Submission time:2021-10-07 20:00:39 +0300
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.01 sdetails
#7ACCEPTED0.01 sdetails
#8ACCEPTED0.01 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.01 sdetails
#11ACCEPTED0.01 sdetails
#12ACCEPTED0.01 sdetails
#13ACCEPTED0.01 sdetails
#14ACCEPTED0.01 sdetails
#15ACCEPTED0.01 sdetails
#16ACCEPTED0.01 sdetails

Compiler report

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

Code

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
	char *str;
	uint16_t n, N, Ns, i, j;

	str = (char *)calloc(sizeof(char), UINT16_MAX);

	scanf("%hd", &n);

	N = (uint16_t)(pow(2, n) - 1);
	Ns = N / 2;


	memset(str, '0', Ns);
	*(str + Ns + 1) = '\0';

	//printf("size: %d, onesize: %d\n", N, Ns);

	for(i = n; i > 1; i--) {
		for(j = 0; j < pow(2, i-2); j++) {
			*(str + ((j+1) * ((uint16_t)pow(2, (n - i) + 1))) - 2 - (uint16_t)(pow(2, n-i) - 1)) = i + 'a' - 1;
			/*printf("%d = %d * %d - %d\tn = %d i = %d\n", ((j+1) * ((uint16_t)pow(2, (n - i)))) - 2 - (uint16_t)(pow(2, n-i + 1) - 1),
				(j+1), (((uint16_t)pow(2, (n - i) + 1))), 2 + (uint16_t)(pow(2, n-i) - 1),
				n, i);
			printf("%s\n", str);*/
		}
	}

	printf("%s%c%s\n", str, 'a', str);

	return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output
a

user output
a

Test 2

Verdict: ACCEPTED

input
2

correct output
bab

user output
bab

Test 3

Verdict: ACCEPTED

input
3

correct output
cbcacbc

user output
cbcacbc

Test 4

Verdict: ACCEPTED

input
4

correct output
dcdbdcdadcdbdcd

user output
dcdbdcdadcdbdcd

Test 5

Verdict: ACCEPTED

input
5

correct output
edecedebedecedeaedecedebedeced...

user output
edecedebedecedeaedecedebedeced...

Test 6

Verdict: ACCEPTED

input
6

correct output
fefdfefcfefdfefbfefdfefcfefdfe...

user output
fefdfefcfefdfefbfefdfefcfefdfe...

Test 7

Verdict: ACCEPTED

input
7

correct output
gfgegfgdgfgegfgcgfgegfgdgfgegf...

user output
gfgegfgdgfgegfgcgfgegfgdgfgegf...

Test 8

Verdict: ACCEPTED

input
8

correct output
hghfhghehghfhghdhghfhghehghfhg...

user output
hghfhghehghfhghdhghfhghehghfhg...

Test 9

Verdict: ACCEPTED

input
9

correct output
ihigihifihigihieihigihifihigih...

user output
ihigihifihigihieihigihifihigih...

Test 10

Verdict: ACCEPTED

input
10

correct output
jijhjijgjijhjijfjijhjijgjijhji...

user output
jijhjijgjijhjijfjijhjijgjijhji...

Test 11

Verdict: ACCEPTED

input
11

correct output
kjkikjkhkjkikjkgkjkikjkhkjkikj...

user output
kjkikjkhkjkikjkgkjkikjkhkjkikj...

Test 12

Verdict: ACCEPTED

input
12

correct output
lkljlklilkljlklhlkljlklilkljlk...

user output
lkljlklilkljlklhlkljlklilkljlk...

Test 13

Verdict: ACCEPTED

input
13

correct output
mlmkmlmjmlmkmlmimlmkmlmjmlmkml...

user output
mlmkmlmjmlmkmlmimlmkmlmjmlmkml...

Test 14

Verdict: ACCEPTED

input
14

correct output
nmnlnmnknmnlnmnjnmnlnmnknmnlnm...

user output
nmnlnmnknmnlnmnjnmnlnmnknmnlnm...

Test 15

Verdict: ACCEPTED

input
15

correct output
onomonolonomonokonomonolonomon...

user output
onomonolonomonokonomonolonomon...

Test 16

Verdict: ACCEPTED

input
16

correct output
popnpopmpopnpoplpopnpopmpopnpo...

user output
popnpopmpopnpoplpopnpopmpopnpo...