Submission #739859

#TimeUsernameProblemLanguageResultExecution timeMemory
739859Desh03Type Printer (IOI08_printer)C++17
10 / 100
27 ms2320 KiB
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, t = 0, p = 0; cin >> n; vector<string> s(n); vector<char> ans; for (string &x : s) cin >> x; sort(s.begin(), s.end(), [&] (const string &s1, const string &s2) { return s1.size() == s2.size() ? s1 < s2 : s1.size() < s2.size(); }); string cur; while (1) { while (cur != s[t]) { cur.push_back(s[t][p]); ans.push_back(s[t][p++]); } ans.push_back('P'); if (t == n - 1) break; t++; while (cur.substr(0, p) != s[t].substr(0, p)) { ans.push_back('-'); cur.pop_back(), --p; } } cout << ans.size() << '\n'; for (int i = 0; i < ans.size(); i++) cout << ans[i] << '\n'; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < ans.size(); i++) cout << ans[i] << '\n';
      |                     ~~^~~~~~~~~~~~
#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...