Submission #1014234

#TimeUsernameProblemLanguageResultExecution timeMemory
1014234MODDIType Printer (IOI08_printer)C++14
30 / 100
23 ms2768 KiB
#include <bits/stdc++.h> using namespace std; int n; string s[25000]; vector<char> res; int main() { cin>>n; for(int i = 0; i < n; i++) cin>>s[i]; sort(s, s + n); int l = 0, r = n - 1, m = 0; for(int i = 1; i < n; i++) if(s[m].length() < s[i].length()) m = i; while(s[l][0] != s[m][0]) l++; while(s[r][0] != s[m][0]) r--; string last = ""; for(int i = 0; i < n; i++) { if(l <= i && i <= r) continue; int j = 0; while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) { j++; } for(int k = j; k < last.size(); k++) res.push_back('-'); for(int k = j; k < s[i].size(); k++) res.push_back(s[i][k]); res.push_back('P'); last = s[i]; } for(int i = l; i <= r; i++) { int j = 0; while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) { j++; } for(int k = j; k < last.size(); k++) res.push_back('-'); for(int k = j; k < s[i].size(); k++) res.push_back(s[i][k]); res.push_back('P'); last = s[i]; } cout<<res.size()<<'\n'; for(auto i : res) cout<<i<<'\n'; return 0; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |               ~~^~~~~~~~~~~~~
printer.cpp:26:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |                                  ~~^~~~~~~~~~~~~
printer.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int k = j; k < last.size(); k++)
      |                        ~~^~~~~~~~~~~~~
printer.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int k = j; k < s[i].size(); k++)
      |                        ~~^~~~~~~~~~~~~
printer.cpp:38:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |               ~~^~~~~~~~~~~~~
printer.cpp:38:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |                                  ~~^~~~~~~~~~~~~
printer.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int k = j; k < last.size(); k++)
      |                        ~~^~~~~~~~~~~~~
printer.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int k = j; 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...