Submission #337835

# Submission time Handle Problem Language Result Execution time Memory
337835 2020-12-22T01:00:39 Z jainbot27 Type Printer (IOI08_printer) C++17
10 / 100
46 ms 4236 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 25001;

string word[mxN];
int n, maxi, maxs;
pair<pair<int, string>, int> v[mxN];
string lst = "";
string res;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=0; i < n; i++) {
        cin >> word[i];
        if(word[i].size() > maxs)
            maxs=word[i].size(), maxi=i;
    }
    for(int i=0; i < n; i++){
        int cnt=0;
        for(int j = 0; j < word[i].size(); j++){
            if(word[i][j]!=word[maxi][j]) break;
            cnt++;
        }
        v[i]={{cnt, word[i]}, i};
    }
    sort(word, word + n);
    for(int i=0; i < n; i++){
        string cur = v[i].first.second;
        cur.resize(25);
        int cnt = 0;
        for(int j =0; j < lst.size(); j++){
            if(lst[j]!=cur[j]) break;
            cnt++;
        }

        cur = v[i].first.second;
        for(int j =0; j < lst.size() - cnt; j++)  res += '-';
        for(int j = cnt; j < cur.size(); j++) res += (cur[j]);
        res+='P';
        lst=cur;
    }
    cout << res.size() << "\n";
    for(int i = 0; i < res.size(); i++) cout << res[i] << '\n';
    return 0;
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:17:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |         if(word[i].size() > maxs)
      |            ~~~~~~~~~~~~~~~^~~~~~
printer.cpp:22:26: 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 j = 0; j < word[i].size(); j++){
      |                        ~~^~~~~~~~~~~~~~~~
printer.cpp:33:25: 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 =0; j < lst.size(); j++){
      |                       ~~^~~~~~~~~~~~
printer.cpp:39:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j =0; j < lst.size() - cnt; j++)  res += '-';
      |                       ~~^~~~~~~~~~~~~~~~~~
printer.cpp:40:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j = cnt; j < cur.size(); j++) res += (cur[j]);
      |                          ~~^~~~~~~~~~~~
printer.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0; i < res.size(); i++) cout << res[i] << '\n';
      |                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2284 KB Output is correct
2 Correct 2 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 4236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 3848 KB Output isn't correct
2 Halted 0 ms 0 KB -