Submission #870338

#TimeUsernameProblemLanguageResultExecution timeMemory
870338Essa2006Type Printer (IOI08_printer)C++14
20 / 100
26 ms2256 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int mp[26]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; vector<string>A(n); string a=""; for(int i=0;i<n;i++){ cin>>A[i]; if(A[i].size()>a.size()) a=A[i]; } sort(all(A)); string last=""; vector<char>Ans; vector<bool>Done(n); for(int f=0;f<a.size();f++){ for(int i=0;i<n;i++){ if(!Done[i] && (A[i].size()>f && A[i][f]!=a[f])){ int cur=last.size()-1; int same=-1; for(int j=0;j<min(last.size(), A[i].size());j++){ if(A[i][j]==last[j]) same=j; else break; } while(cur>same) Ans.push_back('-'), cur--; for(int j=same+1;j<A[i].size();j++){ Ans.push_back(A[i][j]); } Ans.push_back('P'); last=A[i], Done[i]=1; } } } int cur=last.size()-1; int same=-1; for(int j=0;j<min(last.size(), a.size());j++){ if(a[j]==last[j]) same=j; else break; } while(cur>same) Ans.push_back('-'), cur--; for(int j=same+1;j<a.size();j++){ Ans.push_back(a[j]); } last=a; Ans.push_back('P'); cout<<Ans.size()<<endl; for(int i=0;i<Ans.size();i++){ cout<<Ans[i]<<endl; } }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:25:18: 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 f=0;f<a.size();f++){
      |                 ~^~~~~~~~~
printer.cpp:27:40: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             if(!Done[i] && (A[i].size()>f && A[i][f]!=a[f])){
      |                             ~~~~~~~~~~~^~
printer.cpp:30:30: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   30 |                 for(int j=0;j<min(last.size(), A[i].size());j++){
      |                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:38:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |                 for(int j=same+1;j<A[i].size();j++){
      |                                  ~^~~~~~~~~~~~
printer.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   48 |     for(int j=0;j<min(last.size(), a.size());j++){
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int j=same+1;j<a.size();j++){
      |                      ~^~~~~~~~~
printer.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i<Ans.size();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...