Submission #63171

# Submission time Handle Problem Language Result Execution time Memory
63171 2018-08-01T03:27:30 Z nvmdava Type Printer (IOI08_printer) C++17
0 / 100
5 ms 1032 KB
#include<bits/stdc++.h>
using namespace std;

struct Node{
	char val;
	Node *let[26];
	int maxId, lon = 0, size = 0;
	
	bool operator<(const Node* rhs) const{
		if(this == NULL){
			return 1;
		}
		return lon < rhs -> lon;
	}
	
	void sorter(){
		sort(let, let + 26);
		lon = let[25] -> lon + 1;
		for(int i = 0;i <= 25; i++){
			size += let[i] -> size;
		}
		size+=2;
	}
	
} *root[26];

void insert(string s, Node* now, int i, int len){
	if(i == len){
		return;
	}
	if(now -> let[s[i]  - 'a'] == NULL){
		now -> let[s[i]  - 'a'] = new Node;
	}
	now = now -> let[s[i]  - 'a'];
	now -> val = s[i];
	insert(s, now, i + 1, len);
}

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, i;
	
	for(i = 0; i <= 25; i++){
		root[i] = new Node;
	}
	
	cin>>n;
	string s;
	for(i = 1; i <= n; i++){
		cin>>s;
		insert(s, root[s[0] - ' a'], 1, s.size());
	}
	int ans = 0;
	for(i = 1; i <= n; i++){
		root[i] -> sorter();
		ans += root[i] -> size;
	}
	sort(root, root + 26);
	ans -= root[25] -> lon;
	cout<<ans;
}

Compilation message

printer.cpp:55:25: warning: multi-character character constant [-Wmultichar]
   insert(s, root[s[0] - ' a'], 1, s.size());
                         ^~~~
printer.cpp: In function 'int main()':
printer.cpp:55:9: warning: array subscript is below array bounds [-Warray-bounds]
   insert(s, root[s[0] - ' a'], 1, s.size());
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 964 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -