Submission #870286

#TimeUsernameProblemLanguageResultExecution timeMemory
870286Essa2006Type Printer (IOI08_printer)C++14
10 / 100
21 ms2260 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 main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; vector<string>A(n); for(int i=0;i<n;i++){ cin>>A[i]; } sort(all(A)); vector<int>Same(n, -1); for(int i=1;i<n;i++){ for(int j=0;j<min(A[i].size(), A[i-1].size());j++){ if(A[i][j]==A[i-1][j]) Same[i]=j; else break; } } int cur=-1; vector<char>Ans; for(int i=0;i<n;i++){ while(cur>Same[i]) cur--, Ans.push_back('-'); for(int j=Same[i]+1;j<A[i].size();j++){ Ans.push_back(A[i][j]); cur++; } 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:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   20 |         for(int j=0;j<min(A[i].size(), A[i-1].size());j++){
      |                     ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:32:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int j=Same[i]+1;j<A[i].size();j++){
      |                             ~^~~~~~~~~~~~
printer.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     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...