Submission #870286

# Submission time Handle Problem Language Result Execution time Memory
870286 2023-11-07T12:06:34 Z Essa2006 Type Printer (IOI08_printer) C++14
10 / 100
21 ms 2260 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 main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    vector<string>A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    sort(all(A));
    vector<int>Same(n, -1);
    for(int i=1;i<n;i++){
        for(int j=0;j<min(A[i].size(), A[i-1].size());j++){
            if(A[i][j]==A[i-1][j])
                Same[i]=j;
            else
                break;
        }
    }
    int cur=-1;
    vector<char>Ans;
    for(int i=0;i<n;i++){
        while(cur>Same[i])
            cur--, Ans.push_back('-');
        for(int j=Same[i]+1;j<A[i].size();j++){
            Ans.push_back(A[i][j]);
            cur++;
        }
        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:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   20 |         for(int j=0;j<min(A[i].size(), A[i-1].size());j++){
      |                     ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:32:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int j=Same[i]+1;j<A[i].size();j++){
      |                             ~^~~~~~~~~~~~
printer.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 Incorrect 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 2260 KB Output isn't correct
2 Halted 0 ms 0 KB -