Submission #533835

#TimeUsernameProblemLanguageResultExecution timeMemory
533835__VariattoType Printer (IOI08_printer)C++17
0 / 100
26 ms2100 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define ll long long const int MAX=25e3+10, A=30; int n; vector<int>all[A]; string s[MAX]; int naj(string a, string b){ string a1, b1; for(int i=0; i<min(a.size(), b.size()); i++){ a1+=a[i], b1+=b[i]; if(a1!=b1) return i; } return min(a.size(), b.size()); } void wypisz(int i, int j){ int ile=naj(s[i], s[j]); int ile2=s[i].size()-ile; while(ile2--) cout<<"-\n"; for(int k=ile; k<s[j].size(); k++) cout<<s[j][k]<<"\n"; cout<<"P\n"; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin>>n; pair<int,int>maxi={0,0}; for(int i=1; i<=n; i++){ cin>>s[i]; maxi=max(maxi, {s[i].size(), i}); } sort(s+1, s+n+1); int wynik=0, last=0; for(int i=1; i<=n; i++){ if(s[i][0]==s[maxi.se][0]) continue; wynik+=s[last].size()+s[i].size()-2*naj(s[i-1], s[i]); wypisz(last, i); last=i; //cot<<last<<" "<<s[i].size()<<" "<<naj(s[i-1], s[i])<<"\n"; } for(int i=1; i<=n; i++){ if(s[i][0]!=s[maxi.se][0]) continue; wynik+=s[last].size()+s[i].size()-2*naj(s[i-1], s[i]); wypisz(last, i); last=i; } cout<<wynik+n<<"\n"; }

Compilation message (stderr)

printer.cpp: In function 'int naj(std::string, std::string)':
printer.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   13 |     for(int i=0; i<min(a.size(), b.size()); i++){
      |                  ~^~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp: In function 'void wypisz(int, int)':
printer.cpp:25:21: 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 k=ile; k<s[j].size(); k++)
      |                    ~^~~~~~~~~~~~
#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...