Submission #310620

# Submission time Handle Problem Language Result Execution time Memory
310620 2020-10-07T14:00:58 Z Akashi Type Printer (IOI08_printer) C++14
0 / 100
65 ms 35960 KB
#include <bits/stdc++.h>
using namespace std;

struct Trie {
	Trie *fii[26];
	int cnt;

	Trie(){memset(fii, NULL, sizeof(fii)); cnt = 0;}
};

Trie *T = new Trie;

int t, sz;
char s[25];

void add(Trie *nod, char *p){
		if (*p == NULL) {
			nod->cnt++;
			return ;
		}

		if (nod->fii[*p - 'a'] == NULL) ++sz, nod->fii[*p - 'a'] = new Trie;
		add(nod->fii[*p - 'a'], p + 1);
}

void parc(Trie *nod = T) {
	if (nod->cnt)
		printf("P\n");
	
	for (int i = 0; i < 26 ; ++i) {
		if (nod->fii[i] == NULL) continue ;
		printf("%c\n", i + 'a');
		parc(nod->fii[i]);
		printf("-\n");	
	}
}

int main() {
	scanf("%d", &t);
	for (int i = 1; i <= t ; ++i) {
		scanf("%s", s);
		add(T, s);	
	}
	
	printf("%d\n", sz);
	parc();
	return 0;
}

Compilation message

printer.cpp: In constructor 'Trie::Trie()':
printer.cpp:8:21: warning: passing NULL to non-pointer argument 2 of 'void* memset(void*, int, size_t)' [-Wconversion-null]
    8 |  Trie(){memset(fii, NULL, sizeof(fii)); cnt = 0;}
      |                     ^~~~
In file included from /usr/include/features.h:367,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/c++config.h:524,
                 from /usr/include/c++/9/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from printer.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string3.h:78:1: note:   declared here
   78 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
printer.cpp: In function 'void add(Trie*, char*)':
printer.cpp:17:13: warning: NULL used in arithmetic [-Wpointer-arith]
   17 |   if (*p == NULL) {
      |             ^~~~
printer.cpp: In function 'int main()':
printer.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
printer.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1792 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 5888 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 14592 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 35960 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 28152 KB Expected EOF
2 Halted 0 ms 0 KB -