Submission #870338

# Submission time Handle Problem Language Result Execution time Memory
870338 2023-11-07T13:09:33 Z Essa2006 Type Printer (IOI08_printer) C++14
20 / 100
26 ms 2256 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
int mp[26];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    vector<string>A(n);
    string a="";
    for(int i=0;i<n;i++){
        cin>>A[i];
        if(A[i].size()>a.size())
            a=A[i];
    }
    sort(all(A));
    string last="";
    vector<char>Ans;
    vector<bool>Done(n);
    for(int f=0;f<a.size();f++){
        for(int i=0;i<n;i++){
            if(!Done[i] && (A[i].size()>f && A[i][f]!=a[f])){
                int cur=last.size()-1;
                int same=-1;
                for(int j=0;j<min(last.size(), A[i].size());j++){
                    if(A[i][j]==last[j])
                        same=j;
                    else
                        break;
                }
                while(cur>same)
                    Ans.push_back('-'), cur--;
                for(int j=same+1;j<A[i].size();j++){
                    Ans.push_back(A[i][j]);
                }
                Ans.push_back('P');
                last=A[i], Done[i]=1;
            }
        }
    }
    int cur=last.size()-1;
    int same=-1;
    for(int j=0;j<min(last.size(), a.size());j++){
        if(a[j]==last[j])
            same=j;
        else
            break;
    }
    while(cur>same)
        Ans.push_back('-'), cur--;
    for(int j=same+1;j<a.size();j++){
        Ans.push_back(a[j]);
    }
    last=a;
    Ans.push_back('P');
    cout<<Ans.size()<<endl;
    for(int i=0;i<Ans.size();i++){
        cout<<Ans[i]<<endl;
    }
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int f=0;f<a.size();f++){
      |                 ~^~~~~~~~~
printer.cpp:27:40: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             if(!Done[i] && (A[i].size()>f && A[i][f]!=a[f])){
      |                             ~~~~~~~~~~~^~
printer.cpp:30:30: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   30 |                 for(int j=0;j<min(last.size(), A[i].size());j++){
      |                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:38:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |                 for(int j=same+1;j<A[i].size();j++){
      |                                  ~^~~~~~~~~~~~
printer.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   48 |     for(int j=0;j<min(last.size(), a.size());j++){
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int j=same+1;j<a.size();j++){
      |                      ~^~~~~~~~~
printer.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i<Ans.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB didn't print every word
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 600 KB didn't print every word
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB didn't print every word
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB didn't print every word
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 KB didn't print every word
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1248 KB didn't print every word
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2256 KB didn't print every word
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 2004 KB didn't print every word
2 Halted 0 ms 0 KB -