Submission #533835

# Submission time Handle Problem Language Result Execution time Memory
533835 2022-03-07T11:44:40 Z __Variatto Type Printer (IOI08_printer) C++17
0 / 100
26 ms 2100 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=25e3+10, A=30;
int n;
vector<int>all[A];
string s[MAX];
int naj(string a, string b){
    string a1, b1;
    for(int i=0; i<min(a.size(), b.size()); i++){
        a1+=a[i], b1+=b[i];
        if(a1!=b1)
            return i;
    }
    return min(a.size(), b.size());
}
void wypisz(int i, int j){
    int ile=naj(s[i], s[j]);
    int ile2=s[i].size()-ile;
    while(ile2--)
        cout<<"-\n";
    for(int k=ile; k<s[j].size(); k++)
        cout<<s[j][k]<<"\n";
    cout<<"P\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>n;
    pair<int,int>maxi={0,0};
    for(int i=1; i<=n; i++){
        cin>>s[i];
        maxi=max(maxi, {s[i].size(), i});
    }
    sort(s+1, s+n+1);
    int wynik=0, last=0;
    for(int i=1; i<=n; i++){ 
        if(s[i][0]==s[maxi.se][0])
            continue;
        wynik+=s[last].size()+s[i].size()-2*naj(s[i-1], s[i]);
        wypisz(last, i);
        last=i;
        //cot<<last<<" "<<s[i].size()<<" "<<naj(s[i-1], s[i])<<"\n";
    }
    for(int i=1; i<=n; i++){
        if(s[i][0]!=s[maxi.se][0])
            continue;
        wynik+=s[last].size()+s[i].size()-2*naj(s[i-1], s[i]);
        wypisz(last, i);
        last=i;
    }
    cout<<wynik+n<<"\n";
}

Compilation message

printer.cpp: In function 'int naj(std::string, std::string)':
printer.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   13 |     for(int i=0; i<min(a.size(), b.size()); i++){
      |                  ~^~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp: In function 'void wypisz(int, int)':
printer.cpp:25:21: 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 k=ile; k<s[j].size(); k++)
      |                    ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1100 KB Expected integer, but "t" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1104 KB Expected integer, but "e" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1100 KB Expected integer, but "h" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 972 KB Expected integer, but "e" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1100 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1100 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1236 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1472 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 2100 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1808 KB Expected integer, but "b" found
2 Halted 0 ms 0 KB -