Submission #1018849

# Submission time Handle Problem Language Result Execution time Memory
1018849 2024-07-10T10:12:53 Z biserailieva Type Printer (IOI08_printer) C++14
10 / 100
37 ms 5764 KB
#include <bits/stdc++.h>
using namespace std;
 
bool rule(string A, string B)
{
    return A.size()<=B.size();
}
int main()
{
    int n;
    cin>>n;
    string S[n];
    for(int i=0;i<n;i++)
    {
        cin>>S[i];
    }
    sort(S, S+n, rule);
    bool f=true, f2=true;
    int res=0;
    vector<char>V;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<S[i].size();j++)
        {
            if(i==0 || (i!=0 && j>=S[i-1].size()))
            {
                string str3=S[i].substr(j, 1);
                V.push_back(str3[0]);
                res++;
            }
            else
            {
                string str2=S[i-1].substr(j, 1);
                string str3=S[i].substr(j, 1);
                if(str2==str3 && f)
                {
                    continue;
                }
                else
                {
                    V.push_back(str3[0]);
                    res++;
                    f=false;
                }
            }
        }
        f=true;
        V.push_back('P');
        res++;
        if(i<n-1)
        {
            for(int j=0;j<S[i].size();j++)
            {
                string str2=S[i].substr(j, 1);
                string str3=S[i+1].substr(j, 1);
                if(str2==str3 && f2)
                {
                    continue;
                }
                else
                {
                    V.push_back('-');
                    f2=false;
                    res++;
                }
            }
            f2=true;
        }
    }
    cout<<res<<endl;
    for(int i=0;i<res;i++)
    {
        cout<<V[i]<<endl;
    }
    return 0;
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int j=0;j<S[i].size();j++)
      |                     ~^~~~~~~~~~~~
printer.cpp:25:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             if(i==0 || (i!=0 && j>=S[i-1].size()))
      |                                 ~^~~~~~~~~~~~~~~
printer.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             for(int j=0;j<S[i].size();j++)
      |                         ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 1112 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 2468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 37 ms 5764 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -