답안 #238917

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238917 2020-06-13T13:19:09 Z tigicha Type Printer (IOI08_printer) C++14
100 / 100
87 ms 24944 KB
#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

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]);
               ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 19840 KB Output is correct
2 Correct 16 ms 19840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 19968 KB Output is correct
2 Correct 16 ms 19968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 19840 KB Output is correct
2 Correct 16 ms 19840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 19840 KB Output is correct
2 Correct 15 ms 19840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 19840 KB Output is correct
2 Correct 16 ms 19968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 19968 KB Output is correct
2 Correct 17 ms 20096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 20224 KB Output is correct
2 Correct 26 ms 20600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 20732 KB Output is correct
2 Correct 26 ms 20608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 21876 KB Output is correct
2 Correct 87 ms 24304 KB Output is correct
3 Correct 57 ms 23156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 21616 KB Output is correct
2 Correct 85 ms 24944 KB Output is correct
3 Correct 57 ms 23668 KB Output is correct
4 Correct 81 ms 24816 KB Output is correct