Submission #656312

#TimeUsernameProblemLanguageResultExecution timeMemory
656312NakeebType Printer (IOI08_printer)C++17
0 / 100
44 ms2800 KiB
#include<bits/stdc++.h> using namespace std; string c; bool cmp(string &a,string &b) { int cnt1=a.size(),cnt2=b.size(); for(int i=0;i<a.size();i++) if(a[i]!=c[i]) cnt1=i; for(int i=0;i<b.size();i++) if(b[i]!=c[i]) cnt2=i; if(cnt1==cnt2) return a<b; return cnt1<cnt2; } int main() { int n; int mx=0; cin>>n; string s[n]; for(int i=0;i<n;i++) { cin>>s[i]; if(s[i].size()>mx||(s[i].size()==mx&&s[i]>c)) mx=s[i].size(),c=s[i]; } vector<char>ans; sort(s,s+n,cmp); for(int i=0;i<s[0].size();i++) ans.push_back(s[0][i]),ans.push_back('\n'); ans.push_back('p'),ans.push_back('\n'); for(int i=1;i<n;i++) { if(s[i-1].size()>s[i].size()) for(int i=0;i<s[i-1].size()-s[i].size();i++) ans.push_back('-'),ans.push_back('\n'); int sz=min(s[i-1].size(),s[i].size()); int k=0; for(k;k<sz;k++) if(s[i-1][k]!=s[i][k]) break; k--; for(int j=k;j<sz-1;j++) ans.push_back('-'),ans.push_back('\n'); k++; for(;k<s[i].size();k++) ans.push_back(s[i][k]),ans.push_back('\n'); ans.push_back('P'),ans.push_back('\n'); } cout<<ans.size()/2<<endl; for(auto i:ans) cout<<i; }

Compilation message (stderr)

printer.cpp: In function 'bool cmp(std::string&, std::string&)':
printer.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0;i<a.size();i++)
      |                 ~^~~~~~~~~
printer.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<b.size();i++)
      |                 ~^~~~~~~~~
printer.cpp: In function 'int main()':
printer.cpp:25:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         if(s[i].size()>mx||(s[i].size()==mx&&s[i]>c))
      |            ~~~~~~~~~~~^~~
printer.cpp:25:40: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         if(s[i].size()>mx||(s[i].size()==mx&&s[i]>c))
      |                             ~~~~~~~~~~~^~~~
printer.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0;i<s[0].size();i++)
      |                 ~^~~~~~~~~~~~
printer.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for(int i=0;i<s[i-1].size()-s[i].size();i++)
      |                         ~^~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:40:13: warning: statement has no effect [-Wunused-value]
   40 |         for(k;k<sz;k++)
      |             ^
printer.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(;k<s[i].size();k++)
      |              ~^~~~~~~~~~~~
#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...