Submission #870360

# Submission time Handle Problem Language Result Execution time Memory
870360 2023-11-07T13:32:39 Z Essa2006 Type Printer (IOI08_printer) C++14
100 / 100
473 ms 43244 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="", last="";
    map<string, bool>mp;
    for(int i=0;i<n;i++){
        cin>>A[i];
        if(A[i].size()>a.size())
            a=A[i];
        mp[A[i]]=1;
    }
    sort(all(A));
    vector<char>Ans;
    for(int f=0;f<=a.size();f++){
        for(int i=0;i<n;i++){
            if(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){
                int cur=last.size()-1, j=-1;
                while(j+1<min(last.size(), A[i].size()) && last[j+1]==A[i][j+1])
                    j++;
                while(cur>j)
                    Ans.push_back('-'), cur--, last.pop_back();
                j++;
                while(j<A[i].size()){
                    Ans.push_back(A[i][j]), last.push_back(A[i][j++]);
                    if(mp[last])
                        Ans.push_back('P'), mp[last]=0;
                }
            }
        }
    }
    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:41: 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(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){
      |                              ~~~~~~~~~~~^~
printer.cpp:27:66: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){
      |                                                                 ~^~~~~~~~~~
printer.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   29 |                 while(j+1<min(last.size(), A[i].size()) && last[j+1]==A[i][j+1])
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:34:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |                 while(j<A[i].size()){
      |                       ~^~~~~~~~~~~~
printer.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     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 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 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 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 860 KB Output is correct
2 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2652 KB Output is correct
2 Correct 47 ms 5208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6092 KB Output is correct
2 Correct 53 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 14976 KB Output is correct
2 Correct 392 ms 36204 KB Output is correct
3 Correct 213 ms 19592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 11752 KB Output is correct
2 Correct 473 ms 43244 KB Output is correct
3 Correct 257 ms 21960 KB Output is correct
4 Correct 407 ms 40236 KB Output is correct