Submission #237242

# Submission time Handle Problem Language Result Execution time Memory
237242 2020-06-05T11:54:40 Z wildturtle Type Printer (IOI08_printer) C++17
80 / 100
1000 ms 40212 KB
#include<bits/stdc++.h>
using namespace std;
long long n,k,maxx,idx;
pair < long long, string > A[500005];
string s1,s[500005];
vector < char> v;
int main() {
           ios::sync_with_stdio(0);
           cin>>n;
           for(long long i=1;i<=n;i++) {
                      cin>>s[i];
                      if(maxx<s[i].size()) { maxx=s[i].size(); s1=s[i]; }
           }
           for(long long i=1;i<=n;i++) {
                      A[i].second=s[i]; k=0;
                      for(long long j=0;j<s[i].size();j++)
                      if(s[i][j]!=s1[j]) break;
                      else k++;
                      A[i].first=k;
           }
           sort(A+1,A+1+n);
           idx=0;
           for(long long i=1;i<=n;i++) {
                      for(long long j=idx;j<A[i].second.size();j++)
                      v.push_back(A[i].second[j]);
                      v.push_back('P');
                      if(i==n) break;
                      idx=A[i].second.size();
                      for(long long j=0;j<A[i].second.size();j++) {
                                 if(A[i].second[j]!=A[i+1].second[j]) { idx=j; break; }
                      }
                      for(long long j=idx;j<A[i].second.size();j++)
                      v.push_back('-');
           }
           cout<<v.size()<<endl;
           for(long long i=0;i<v.size();i++)
           cout<<v[i]<<endl;
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:12:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                       if(maxx<s[i].size()) { maxx=s[i].size(); s1=s[i]; }
                          ~~~~^~~~~~~~~~~~
printer.cpp:16:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                       for(long long j=0;j<s[i].size();j++)
                                         ~^~~~~~~~~~~~
printer.cpp:24:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                       for(long long j=idx;j<A[i].second.size();j++)
                                           ~^~~~~~~~~~~~~~~~~~~
printer.cpp:29:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                       for(long long j=0;j<A[i].second.size();j++) {
                                         ~^~~~~~~~~~~~~~~~~~~
printer.cpp:32:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                       for(long long j=idx;j<A[i].second.size();j++)
                                           ~^~~~~~~~~~~~~~~~~~~
printer.cpp:36:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
            for(long long i=0;i<v.size();i++)
                              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 25 ms 35584 KB Output is correct
2 Correct 26 ms 35584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 35712 KB Output is correct
2 Correct 28 ms 35584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 35584 KB Output is correct
2 Correct 27 ms 35584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 35584 KB Output is correct
2 Correct 29 ms 35584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 35584 KB Output is correct
2 Correct 42 ms 35584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 35680 KB Output is correct
2 Correct 66 ms 35712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 35832 KB Output is correct
2 Correct 234 ms 36216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 284 ms 36212 KB Output is correct
2 Correct 112 ms 36088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 677 ms 37296 KB Output is correct
2 Execution timed out 1076 ms 39664 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 536 ms 36652 KB Output is correct
2 Execution timed out 1095 ms 40212 KB Time limit exceeded
3 Halted 0 ms 0 KB -