답안 #1014234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014234 2024-07-04T14:48:59 Z MODDI Type Printer (IOI08_printer) C++14
30 / 100
23 ms 2768 KB
#include <bits/stdc++.h>
using namespace std;

int n;
string s[25000];
vector<char> res;

int main() {
    cin>>n;
    for(int i = 0; i < n; i++)
        cin>>s[i];
    sort(s, s + n);
    int l = 0, r = n - 1, m = 0;
    for(int i = 1; i < n; i++)
        if(s[m].length() < s[i].length())
            m = i;
    while(s[l][0] != s[m][0])
        l++;
    while(s[r][0] != s[m][0])
        r--;
    string last = "";
    for(int i = 0; i < n; i++) {
        if(l <= i && i <= r)
            continue;
        int j = 0;
        while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
            j++;
        }
        for(int k = j; k < last.size(); k++)
            res.push_back('-');
        for(int k = j; k < s[i].size(); k++)
            res.push_back(s[i][k]);
        res.push_back('P');
        last = s[i];
    }
    for(int i = l; i <= r; i++) {
        int j = 0;
        while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
            j++;
        }
        for(int k = j; k < last.size(); k++)
            res.push_back('-');
        for(int k = j; k < s[i].size(); k++)
            res.push_back(s[i][k]);
        res.push_back('P');
        last = s[i];
    }
    cout<<res.size()<<'\n';
    for(auto i : res)
        cout<<i<<'\n';
    return 0;
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |               ~~^~~~~~~~~~~~~
printer.cpp:26:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |                                  ~~^~~~~~~~~~~~~
printer.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int k = j; k < last.size(); k++)
      |                        ~~^~~~~~~~~~~~~
printer.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int k = j; k < s[i].size(); k++)
      |                        ~~^~~~~~~~~~~~~
printer.cpp:38:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |               ~~^~~~~~~~~~~~~
printer.cpp:38:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         while(j < last.size() && j < s[i].size() && last[j] == s[i][j]) {
      |                                  ~~^~~~~~~~~~~~~
printer.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int k = j; k < last.size(); k++)
      |                        ~~^~~~~~~~~~~~~
printer.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int k = j; k < s[i].size(); k++)
      |                        ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1220 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Incorrect 10 ms 1628 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2256 KB Output isn't correct
2 Halted 0 ms 0 KB -