Submission #742691

#TimeUsernameProblemLanguageResultExecution timeMemory
742691petezaType Printer (IOI08_printer)C++14
50 / 100
39 ms2392 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<pair<string, int>> inp; string x, lng; string cur; queue<char> q; int main() { cin.tie(0) -> sync_with_stdio(0); cin >> n; for(int i=0;i<n;i++) { cin >> x; inp.emplace_back(x, -1); if(x.size() > lng.size()) lng = x; } for(int i=0;i<n;i++) { for(int j=0;j<inp[i].first.size();j++) { if(inp[i].first[j] != lng[j]) { inp[i].second = j; break; } } if(inp[i].second == -1) inp[i].second = x.size(); } sort(inp.begin(), inp.end(), [](pair<string, int> a, pair<string, int> b){ if(a.second == b.second) return a.first < b.first; else return a.second < b.second; }); for(int i=0;i<n;i++) { while(inp[i].first.substr(0, cur.size()) != cur) cur.pop_back(), q.push('-'); for(int j=cur.size();j<inp[i].first.size();j++) cur += inp[i].first[j], q.push(inp[i].first[j]); q.push('P'); } cout << q.size() << '\n'; while(!q.empty()) cout << q.front() << '\n', q.pop(); }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int j=0;j<inp[i].first.size();j++) {
      |                     ~^~~~~~~~~~~~~~~~~~~~
printer.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int j=cur.size();j<inp[i].first.size();j++) cur += inp[i].first[j], q.push(inp[i].first[j]);
      |                              ~^~~~~~~~~~~~~~~~~~~~
#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...