Submission #870342

#TimeUsernameProblemLanguageResultExecution timeMemory
870342Essa2006Type Printer (IOI08_printer)C++14
100 / 100
454 ms44008 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=""; map<string, bool>mp; for(int i=0;i<n;i++){ cin>>A[i]; if(A[i].size()>a.size()) a=A[i]; mp[A[i]]=1; } sort(all(A)); string last=""; vector<char>Ans; for(int f=0;f<a.size();f++){ for(int i=0;i<n;i++){ if(mp[A[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--, last.pop_back(); for(int j=same+1;j<A[i].size();j++){ Ans.push_back(A[i][j]); last.push_back(A[i][j]); if(mp[last]){ Ans.push_back('P'); mp[last]=0; } } } } } 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--, last.pop_back(); for(int j=same+1;j<a.size();j++){ Ans.push_back(a[j]); last.push_back(a[j]); if(mp[last]){ Ans.push_back('P'); mp[last]=0; } } 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:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int f=0;f<a.size();f++){
      |                 ~^~~~~~~~~
printer.cpp:28:40: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |             if(mp[A[i]] && (A[i].size()>f && A[i][f]!=a[f])){
      |                             ~~~~~~~~~~~^~
printer.cpp:31:30: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   31 |                 for(int j=0;j<min(last.size(), A[i].size());j++){
      |                             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:39:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |                 for(int j=same+1;j<A[i].size();j++){
      |                                  ~^~~~~~~~~~~~
printer.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   52 |     for(int j=0;j<min(last.size(), a.size());j++){
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:60:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int j=same+1;j<a.size();j++){
      |                      ~^~~~~~~~~
printer.cpp:69:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     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...