Submission #855097

# Submission time Handle Problem Language Result Execution time Memory
855097 2023-09-30T07:06:17 Z vjudge1 Type Printer (IOI08_printer) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
const int sig=26,nn=25000;
struct node{
	int ch[sig];
	bool mark,end;
}t[nn*20]; 
int sz=0;
void insert(const string& s){
	int u=0;
	for(char c:s){
		int d=c-'a',&cu=t[u].ch[d];
		if(!cu) cu+=sz;
		u=cu;
	}
	t[u].end=true;
}
void dfs(int u,string& ans){
	const node& x=t[u];
	if(x.end) ans+='p';
	int mi=-1;
	for(in i=0;i<sig;i++){
		int v=x.ch[i]
		if(!v) continue;
		if(t[v].mark)
			mi=i;
		else
			ans+=i+'a',dfs(v,ans);
	}
	if(mi=-1)
		ans+=mi+'a',dfs(x.ch[i],ans);
	ans+='-';
}
int main(){
    int n;
    cin>>n;
    string s,l;
    for(int i0=;i<n;i++){
    	cin>>s,insert(s);
    	if(s.length()>l.length()) l=s;
	}
	for(size_t i=0,u=0;i<l.size();i++)
		u=t[u].ch[l[i]-'a'],t[u].mark=true;
	s.clear(),dfs(0,s);
	while(s.back=='-') s.pop_back();
	cout<<s.size()<<'\n';
	for(char c:s) cout<<c<<"\n";
	return 0;
}

Compilation message

printer.cpp: In function 'void dfs(int, std::string&)':
printer.cpp:22:6: error: 'in' was not declared in this scope; did you mean 'nn'?
   22 |  for(in i=0;i<sig;i++){
      |      ^~
      |      nn
printer.cpp:22:13: error: 'i' was not declared in this scope; did you mean 'mi'?
   22 |  for(in i=0;i<sig;i++){
      |             ^
      |             mi
printer.cpp:30:7: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   30 |  if(mi=-1)
      |     ~~^~~
printer.cpp:31:24: error: 'i' was not declared in this scope; did you mean 'mi'?
   31 |   ans+=mi+'a',dfs(x.ch[i],ans);
      |                        ^
      |                        mi
printer.cpp: In function 'int main()':
printer.cpp:38:16: error: expected primary-expression before ';' token
   38 |     for(int i0=;i<n;i++){
      |                ^
printer.cpp:38:17: error: 'i' was not declared in this scope; did you mean 'i0'?
   38 |     for(int i0=;i<n;i++){
      |                 ^
      |                 i0
printer.cpp:38:13: warning: unused variable 'i0' [-Wunused-variable]
   38 |     for(int i0=;i<n;i++){
      |             ^~
printer.cpp:45:14: error: invalid operands of types '<unresolved overloaded function type>' and 'char' to binary 'operator=='
   45 |  while(s.back=='-') s.pop_back();
      |        ~~~~~~^~~~~
      |          |     |
      |          |     char
      |          <unresolved overloaded function type>