Submission #739859

# Submission time Handle Problem Language Result Execution time Memory
739859 2023-05-11T12:31:26 Z Desh03 Type Printer (IOI08_printer) C++17
10 / 100
27 ms 2320 KB
#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

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 time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 2320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 2172 KB Output isn't correct
2 Halted 0 ms 0 KB -