Submission #238917

#TimeUsernameProblemLanguageResultExecution timeMemory
238917tigichaType Printer (IOI08_printer)C++14
100 / 100
87 ms24944 KiB
#include<bits/stdc++.h> using namespace std; long long n, k, mx, t; pair<long long, string>a[500005]; char s1[22], s[25004][22]; vector<char>v; int main(){ scanf("%d", &n); for(long long i=1; i<=n; i++){ scanf("%s", s[i]); if(mx<strlen(s[i])){ mx=strlen(s[i]); k=i; } } for(long long i=0; i<strlen(s[k]); i++) s1[i]=s[k][i]; for(long long i=1; i<=n; i++){ a[i].second=s[i]; t=0; for(long long j=0; j<strlen(s[i]); j++) if(s[i][j]!=s1[j]) break; else t++; a[i].first=t; } sort(a+1, a+n+1); k=0; for(long long i=1; i<=n; i++){ for(long long j=k; j<a[i].second.size(); j++) v.push_back(a[i].second[j]); v.push_back('P'); if(i==n) break; k=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]){ k=j; break; } for(long long j=k; j<a[i].second.size(); j++) v.push_back('-'); } printf("%d\n", v.size()); for(long long i=0; i<v.size(); i++) printf("%c\n", v[i]); }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:8:22: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
        scanf("%d", &n);
                    ~~^
printer.cpp:11:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               if(mx<strlen(s[i])){
                  ~~^~~~~~~~~~~~~
printer.cpp:16:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
        for(long long i=0; i<strlen(s[k]); i++)
                           ~^~~~~~~~~~~~~
printer.cpp:21:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               for(long long j=0; j<strlen(s[i]); j++)
                                  ~^~~~~~~~~~~~~
printer.cpp:29:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               for(long long j=k; j<a[i].second.size(); j++)
                                  ~^~~~~~~~~~~~~~~~~~~
printer.cpp:34:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               for(long long j=0; j<a[i].second.size(); j++)
                                  ~^~~~~~~~~~~~~~~~~~~
printer.cpp:39:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               for(long long j=k; j<a[i].second.size(); j++)
                                  ~^~~~~~~~~~~~~~~~~~~
printer.cpp:42:31: 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", v.size());
                       ~~~~~~~~^
printer.cpp:43:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
        for(long long i=0; i<v.size(); i++)
                           ~^~~~~~~~~
printer.cpp:8:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
        scanf("%d", &n);
        ~~~~~^~~~~~~~~~
printer.cpp:10:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
               scanf("%s", s[i]);
               ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...