Submission #115193

#TimeUsernameProblemLanguageResultExecution timeMemory
115193CaroLindaType Printer (IOI08_printer)C++14
100 / 100
136 ms49016 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define lp(i,a,b) for(int i=a;i<b;i++) #define ll long long #define ff first #define ss second #define pb push_back const int MAXN = 25002; const int ALF= 26; using namespace std ; int n ; int trie[MAXN*20][ALF] , cnt ; int separa = 1 ; vector<char> ans ; bool marc[MAXN*20] ; void add( string str ) { int t = str.size() ; int cur = 0 ; lp(i,0,t) { int k = str[i] - 'a' ; if(trie[cur][k] == 0) trie[cur][k] = ++cnt ; cur = trie[cur][k] ; } marc[cur] =true; } void dfs(int x) { if(marc[x]) printf("P\n") ; int ok= -1 ; lp(i,0,26) { if( trie[x][i] == separa ) { ok = i+'a' ; continue ; } if(trie[x][i] == 0) continue ; printf("%c\n", i+'a') ; dfs( trie[x][i] ) ; printf("-\n"); } if(ok!=-1) { printf("%c\n", ok) ; dfs(separa++) ; } } int main() { scanf("%d", &n); string v[MAXN] ; cin>>v[0] ; lp(i,1,n) { cin>>v[i] ; if( v[i].size() > v[0].size() ) swap(v[0] , v[i]) ; } lp(i,0,n) add(v[i]) ; printf("%d\n" ,cnt*2 + n - v[0].size() ) ; dfs(0) ; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:82:41: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::__cxx11::basic_string<char>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n" ,cnt*2 + n - v[0].size() ) ;
                 ~~~~~~~~~~~~~~~~~~~~~~~ ^
printer.cpp:68:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...