Submission #870361

#TimeUsernameProblemLanguageResultExecution timeMemory
870361Essa2006Type Printer (IOI08_printer)C++17
100 / 100
457 ms43288 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="", last=""; 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)); 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]) || f==a.size())){ int cur=last.size()-1, j=-1; while(j+1<min(last.size(), A[i].size()) && last[j+1]==A[i][j+1]) j++; while(cur>j) Ans.push_back('-'), cur--, last.pop_back(); j++; while(j<A[i].size()){ Ans.push_back(A[i][j]), last.push_back(A[i][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: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:41: 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(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){
      |                              ~~~~~~~~~~~^~
printer.cpp:27:66: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if(mp[A[i]] && ((A[i].size()>f && A[i][f]!=a[f]) || f==a.size())){
      |                                                                 ~^~~~~~~~~~
printer.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   29 |                 while(j+1<min(last.size(), A[i].size()) && last[j+1]==A[i][j+1])
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:34:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |                 while(j<A[i].size()){
      |                       ~^~~~~~~~~~~~
printer.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     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...