답안 #870361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870361 2023-11-07T13:33:37 Z Essa2006 Type Printer (IOI08_printer) C++17
100 / 100
457 ms 43288 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++){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 860 KB Output is correct
2 Correct 7 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 2648 KB Output is correct
2 Correct 47 ms 5204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 5936 KB Output is correct
2 Correct 47 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 15044 KB Output is correct
2 Correct 379 ms 36204 KB Output is correct
3 Correct 209 ms 19400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 11728 KB Output is correct
2 Correct 457 ms 43288 KB Output is correct
3 Correct 270 ms 21920 KB Output is correct
4 Correct 414 ms 40388 KB Output is correct