Submission #236384

#TimeUsernameProblemLanguageResultExecution timeMemory
236384gurkotType Printer (IOI08_printer)C++11
0 / 100
30 ms896 KiB
#include <iostream> #include <algorithm> using namespace std; string S; struct Word{ string s;}; bool operator <(Word a, Word b){ int ka=0,kb=0; for (int i=0;i<a.s.size();i++) if (a.s[i]==S[i]) ka++; else break; for (int i=0;i<b.s.size();i++) if (b.s[i]==S[i]) kb++; else break; return ka<kb || ka==kb && a.s<b.s; } Word word[2500]; int n,lmax,l; main(){ ios::sync_with_stdio(0); cin>>n; for (int i=0;i<n;i++) { cin>>word[i].s; l=word[i].s.size(); if (lmax<l){ lmax=l; S=word[i].s; } } sort(word,word+n); int pos0=0; for (int i=0;i<word[0].s.size();i++) cout<<word[0].s[i]<<endl; cout<<"P"<<endl; for (int i=1;i<n;i++){ int k=0; for (int j=0;j<min(word[i-1].s.size(),word[i].s.size());j++) if(word[i-1].s[j]==word[i].s[j]) k++; else break; l=word[i-1].s.size(); for (int j=1;j<=l-k;j++) cout<<"-"<<endl; for (int j=k;j<word[i].s.size();j++) cout<<word[i].s[j]<<endl; cout<<"P"<<endl; } } /* 3 print the poem */

Compilation message (stderr)

printer.cpp: In function 'bool operator<(Word, Word)':
printer.cpp:9:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0;i<a.s.size();i++)
               ~^~~~~~~~~~~
printer.cpp:12:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0;i<b.s.size();i++)
               ~^~~~~~~~~~~
printer.cpp:15:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  return ka<kb || ka==kb && a.s<b.s;
                  ~~~~~~~^~~~~~~~~~
printer.cpp: At global scope:
printer.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
printer.cpp: In function 'int main()':
printer.cpp:36:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0;i<word[0].s.size();i++) cout<<word[0].s[i]<<endl;
               ~^~~~~~~~~~~~~~~~~
printer.cpp:41:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=0;j<min(word[i-1].s.size(),word[i].s.size());j++)
                ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:46:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=k;j<word[i].s.size();j++) cout<<word[i].s[j]<<endl;
                ~^~~~~~~~~~~~~~~~~
printer.cpp:35:6: warning: unused variable 'pos0' [-Wunused-variable]
  int pos0=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...