Submission #924972

#TimeUsernameProblemLanguageResultExecution timeMemory
924972vjudge1Type Printer (IOI08_printer)C++17
100 / 100
492 ms43128 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; vector<string>A(n); string a="", last=""; map<string, bool>mp; for(int i=0;i<n;i++){ cin>>A[i]; if(A[i].size()>a.size()) a=A[i]; mp[A[i]]=1; } sort(A.begin(), A.end()); vector<char>Ans; for(int f=0;f<=a.size();f++){ for(int i=0;i<n;i++){ if(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){ int cur=last.size()-1, j=-1; while(j+1<min(last.size(), A[i].size()) && last[j+1]==A[i][j+1]) j++; while(cur>j) Ans.push_back('-'), cur--, last.pop_back(); j++; while(j<A[i].size()){ Ans.push_back(A[i][j]), last.push_back(A[i][j++]); if(mp[last]) Ans.push_back('P'), mp[last]=0; } } } } cout<<Ans.size()<<'\n'; for(int i=0;i<Ans.size();i++){ cout<<Ans[i]<<'\n'; } }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:18:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int f=0;f<=a.size();f++){
      |                 ~^~~~~~~~~~
printer.cpp:20:41: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |             if(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){
      |                              ~~~~~~~~~~~^~
printer.cpp:20:66: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             if(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){
      |                                                                 ~^~~~~~~~~~
printer.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   22 |                 while(j+1<min(last.size(), A[i].size()) && last[j+1]==A[i][j+1])
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:27:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |                 while(j<A[i].size()){
      |                       ~^~~~~~~~~~~~
printer.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<Ans.size();i++){
      |                 ~^~~~~~~~~~~
#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...