Submission #956773

#TimeUsernameProblemLanguageResultExecution timeMemory
956773DeltaStructType Printer (IOI08_printer)C++17
30 / 100
841 ms5684 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<string> A(n); for (auto& a:A) cin >> a; sort(A.begin(),A.end()); string s,r; int mx = numeric_limits<int>::max(); for (int m(0);m < n;++m){ //int m = lower_bound(A.begin(),A.end(),to_string(x))-A.begin(); if (m) while(A[m-1][0]==A[m][0]){ ++m; if (m==n) break; } if (m==n) continue; for (int i(m);i < n;++i){ int t(0); if (i!=m) for (int k(0);;++k,++t) if (A[i-1].size()==k||A[i].size()==k||A[i-1][k]!=A[i][k]) break; if (i!=m) for (int k(t);k < A[i-1].size();++k) s += '-'; for (int k(t);k < A[i].size();++k) s += A[i][k]; s += 'P'; } for (int i(0);i < m;++i){ int t(0); if (m!=n) for (int k(0);;++k,++t) if (A[(i?i:n)-1].size()==k||A[i].size()==k||A[(i?i:n)-1][k]!=A[i][k]) break; if (n!=m) for (int k(t);k < A[(i?i:n)-1].size();++k) s += '-'; for (int k(t);k < A[i].size();++k) s += A[i][k]; s += 'P'; } if (mx>s.size()) mx = s.size(),r = s; s = ""; } cout << mx << endl; for (char a:r) cout << a << endl; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:13:58: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |       if (i!=m) for (int k(0);;++k,++t) if (A[i-1].size()==k||A[i].size()==k||A[i-1][k]!=A[i][k]) break;
      |                                             ~~~~~~~~~~~~~^~~
printer.cpp:13:74: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |       if (i!=m) for (int k(0);;++k,++t) if (A[i-1].size()==k||A[i].size()==k||A[i-1][k]!=A[i][k]) break;
      |                                                               ~~~~~~~~~~~^~~
printer.cpp:14:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |       if (i!=m) for (int k(t);k < A[i-1].size();++k) s += '-';
      |                               ~~^~~~~~~~~~~~~~~
printer.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |       for (int k(t);k < A[i].size();++k) s += A[i][k];
      |                     ~~^~~~~~~~~~~~~
printer.cpp:20:64: 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 (m!=n) for (int k(0);;++k,++t) if (A[(i?i:n)-1].size()==k||A[i].size()==k||A[(i?i:n)-1][k]!=A[i][k]) break;
      |                                             ~~~~~~~~~~~~~~~~~~~^~~
printer.cpp:20:80: 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 (m!=n) for (int k(0);;++k,++t) if (A[(i?i:n)-1].size()==k||A[i].size()==k||A[(i?i:n)-1][k]!=A[i][k]) break;
      |                                                                     ~~~~~~~~~~~^~~
printer.cpp:21:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |       if (n!=m) for (int k(t);k < A[(i?i:n)-1].size();++k) s += '-';
      |                               ~~^~~~~~~~~~~~~~~~~~~~~
printer.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |       for (int k(t);k < A[i].size();++k) s += A[i][k];
      |                     ~~^~~~~~~~~~~~~
printer.cpp:25:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     if (mx>s.size()) mx = s.size(),r = s;
      |         ~~^~~~~~~~~
#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...