제출 #1254663

#제출 시각아이디문제언어결과실행 시간메모리
1254663mngoc._.Vještica (COCI16_vjestica)C++20
0 / 160
32 ms47940 KiB
#include<bits/stdc++.h>

using namespace std;
const int NUMBEROFNODE = 2e6 + 5;
struct trie{
	struct node{
		int child[26];
		int exist , cnt;
	} nodes[NUMBEROFNODE];
	
	int cur;
	trie() : cur(0) {
        memset(nodes[0].child , -1 , sizeof(nodes[0].child));
		nodes[0].exist = nodes[0].cnt = 0;		
	};
	
	int new_node(){
		cur++;
		memset(nodes[cur].child , -1 , sizeof(nodes[cur].child));
		nodes[cur].exist = nodes[cur].cnt = 0;
		return cur;
	}
	
	void add_string(string s){
		int pos = 0;
		for(auto f : s){
			int t = f - 'a';
			if(nodes[pos].child[t] == -1) nodes[pos].child[t] = new_node();
			pos = nodes[pos].child[t];
			nodes[pos].cnt++;
		}
		nodes[pos].exist++;
	}	
} Trie;


void solve(void){
	string t; cin >> t;
	sort(t.begin() , t.end());
	Trie.add_string(t);
	
}

int main(void){
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	int testCase; cin >> testCase;
	while(testCase--){
		solve();
	}
	cout << Trie.cur + 1;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...