Submission #122183

# Submission time Handle Problem Language Result Execution time Memory
122183 2019-06-27T19:30:35 Z thebes Type Printer (IOI08_printer) C++14
10 / 100
49 ms 2676 KB
#include <bits/stdc++.h>
using namespace std;

string s, arr[25005], lol;
int n, i, j, x, ord[26], nxt=25; vector<char> mv;
bool cmp(string i,string j){
    for(int ii=0;ii<min(i.size(),j.size());ii++){
        if(i[ii]!=j[ii]) return ord[i[ii]-'a']<ord[j[ii]-'a'];
    }
    return i.size()<j.size();
}

int main(){
    for(scanf("%d",&n),i=1;i<=n;i++){
        cin >> arr[i];
        if(arr[i].size()>lol.size())
            lol = arr[i];
    }
    for(auto v : lol){
        if(ord[v-'a']) continue;
        ord[v-'a']=nxt--;
    }
    for(i=25;i>=0;i--){
        if(ord[i]) continue;
        ord[i]=nxt--;
    }
    sort(arr+1,arr+n+1,cmp);
    for(i=1;i<=n;i++){
        for(j=0;j<min(s.size(),arr[i].size());j++){
            if(s[j]!=arr[i][j]) break;
        }
        while(s.size()>j){
            mv.push_back('-');
            s.pop_back();
        }
        while(s.size()<arr[i].size()){
            s.push_back(arr[i][s.size()]);
            mv.push_back(arr[i][s.size()-1]);
        }
        mv.push_back('P');
    }
    printf("%d\n",mv.size());
    for(auto v : mv) printf("%c\n",v);
    return 0;
}

Compilation message

printer.cpp: In function 'bool cmp(std::__cxx11::string, std::__cxx11::string)':
printer.cpp:7:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int ii=0;ii<min(i.size(),j.size());ii++){
                  ~~^~~~~~~~~~~~~~~~~~~~~~~
printer.cpp: In function 'int main()':
printer.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0;j<min(s.size(),arr[i].size());j++){
                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:32:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(s.size()>j){
               ~~~~~~~~^~
printer.cpp:42:28: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<char>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",mv.size());
                   ~~~~~~~~~^
printer.cpp:14:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d",&n),i=1;i<=n;i++){
         ~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Correct 2 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Incorrect 3 ms 1024 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 2676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 2160 KB Output isn't correct
2 Halted 0 ms 0 KB -