Submission #909893

#TimeUsernameProblemLanguageResultExecution timeMemory
909893Mehrad2Type Printer (IOI08_printer)C++17
20 / 100
46 ms55476 KiB
#include<bits/stdc++.h> /* @@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ @@! @@! @@! @@! @@! @@@ @@! @@@ @@! @@@ @@! @@@ !@! !@! !@! !@! !@! @!@ !@! @!@ !@! @!@ !@! @!@ @!! !!@ @!@ @!!!:! @!@!@!@! @!@!!@! @!@!@!@! @!@ !@! !@! ! !@! !!!!!: !!!@!!!! !!@!@! !!!@!!!! !@! !!! !!: !!: !!: !!: !!! !!: :!! !!: !!! !!: !!! :!: :!: :!: :!: !:! :!: !:! :!: !:! :!: !:! ::: :: :: :::: :: ::: :: ::: :: ::: :::: :: : : : :: :: : : : : : : : : : :: : : */ using namespace std; #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define all(v) v.begin(),v.end() #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define sz(x) int(x.size()) #define mp make_pair #define pb push_back #define S second #define F first #define pss ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define jame(a,b) a=(a+b)%mod #define taf(a,b) a=(a+2*mod-b)%mod typedef long long ll; typedef double dbl; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,pair<int,int>> piii; typedef pair<int,long long> pil; typedef pair<long long,int> pli; const long long xn =1e6+5,mod=1e9+7; map<char,int> ti[xn]; int cnt=1,n; string s,ans; void add(){ int cur=1; f(i,0,sz(s)){ if(!ti[cur][s[i]])ti[cur][s[i]]=++cnt; cur=ti[cur][s[i]]; } } void dfs(int v,int h,bool mark){ if(sz(ti[v])==0){ cout<<"P\n"; return; } for(pair<char,int> x:ti[v]){ if(mark && x.F==ans[h])continue; cout<<x.F<<'\n'; dfs(x.S,h+1,0); cout<<'-'<<'\n'; } if(!mark)return; cout<<ans[h]<<'\n'; dfs(ti[v][ans[h]],h+1,1); } int main(){ pss cin>>n; f(i,0,n){ cin>>s; if(sz(s)>sz(ans))ans=s; add(); } cout<<(cnt-1)*2-sz(ans)+n<<'\n'; dfs(1,0,1); return 0; }
#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...