답안 #800228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800228 2023-08-01T12:28:21 Z Liudas Type Printer (IOI08_printer) C++17
30 / 100
707 ms 7252 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    vector<string> arr(N);
    for(string &i : arr)cin >> i;
    sort(arr.begin(), arr.end());
    arr.push_back("");
    vector<char> brr;
    vector<string> ans;
    string temp = "P";
    for(string i : arr){
        int k = 0;
        while(k < brr.size() && k < i.size() && brr[k] == i[k]){
            k++;
        }
        int t = brr.size();
        for(int j = k; j < t; j ++){
            temp += "-";
            brr.pop_back();
        }
        if(k == 0){
            ans.push_back(temp);
            temp = "";
        }
        for(int j = k; j < i.size(); j ++){
            brr.push_back(i[j]);
            temp += i.substr(j, 1);
        }
        temp += "P";
    }
    ans.erase(ans.begin());
    map<string, int> len;
    for(string i : ans){
        int t = count(i.begin(), i.begin() + i.rfind('P'), '-');
        int tt = count(i.begin(), i.end(), 'P');
        int ttt = i.rfind('P') -  2 * t - tt + 1;
        len[i] = ttt;
    }
    sort(ans.begin(), ans.end(), [&](string a, string b){return len[a] < len[b];});
    vector<char> a2;
    for(string i : ans){
        for(char j : i){
            a2.push_back(j);
        }
    }
    while(a2.back() =='-')a2.pop_back();
    cout << a2.size() << endl;
    for(char i : a2){
        cout << i << endl;
    }
    return 0;
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         while(k < brr.size() && k < i.size() && brr[k] == i[k]){
      |               ~~^~~~~~~~~~~~
printer.cpp:19:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         while(k < brr.size() && k < i.size() && brr[k] == i[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 j = k; j < i.size(); j ++){
      |                        ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 752 KB Output is correct
2 Incorrect 108 ms 1300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 134 ms 1584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 337 ms 3508 KB Output is correct
2 Correct 707 ms 7252 KB Output is correct
3 Incorrect 390 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 271 ms 3100 KB Output isn't correct
2 Halted 0 ms 0 KB -