답안 #310619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310619 2020-10-07T14:00:14 Z Akashi Type Printer (IOI08_printer) C++14
0 / 100
63 ms 36088 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;
char s[25];

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

		if (nod->fii[*p - 'a'] == NULL) 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);	
	}
	
	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);
      |   ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Expected integer, but "t" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Expected integer, but "e" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Expected integer, but "h" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Expected integer, but "b" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1792 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 5888 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 14456 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 36088 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 28152 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -