#include <bits/stdc++.h> using namespace std; int main() { long long numc=0,wyn=0; int won=-1; long long sis; string in,lastin; long long n,zc=0; cin>>n; cin>>lastin; while(--n) { cin>>in; if(in.size()<lastin.size()+zc) { cout<<in<<" "<<wyn<<" "<<zc<<endl; //cout<<"zc: "<<zc<<" wyn: "<<wyn<<endl; if(in<=lastin) { won=-1; sis=in.size(); cout<<in<<endl; for(int i=sis; i<lastin.size();++i) { cout<<"sd"<<lastin<<endl; //cout<<"sd"; if((int)lastin[i]<57) { cout<<"ddd"; wyn=wyn+i-sis+1; won=1; in=in+(char)(lastin[i]+1); zc=0; break; } in+="0"; } if(won!=1) { //cout<<"Xd"; wyn=wyn+lastin.size()-sis+1+zc; zc=1; } } else { //cout<<n<<" "<<zc<<" f"; zc=zc+lastin.size()-in.size(); //cout<<lastin.size()<<" "<<in.size()<<endl; wyn+=zc; } } else if(in.size()==lastin.size()+zc && in<=lastin) { ++wyn; zc=1; } else { zc=0; } lastin=in; cout<<zc<<" "<<endl; } cout<<wyn; return 0; /* string a,b; while(1) {cin>>a>>b; if(a>b) { cout<<1; } else if(a<b) { cout<<0; } else if(a==b) { cout<<-1; } cout<<endl; }*/ }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #include <bits/stdc++.h> using namespace std; int main() { long long numc=0,wyn=0; int won=-1; long long sis; string in,lastin; long long n,zc=0; cin>>n; cin>>lastin; while(--n) { cin>>in; if(in.size()<lastin.size()+zc) { cout<<in<<" "<<wyn<<" "<<zc<<endl; //cout<<"zc: "<<zc<<" wyn: "<<wyn<<endl; if(in<=lastin) { won=-1; sis=in.size(); cout<<in<<endl; for(int i=sis; i<lastin.size();++i) { cout<<"sd"<<lastin<<endl; //cout<<"sd"; if((int)lastin[i]<57) { cout<<"ddd"; wyn=wyn+i-sis+1; won=1; in=in+(char)(lastin[i]+1); zc=0; break; } in+="0"; } if(won!=1) { //cout<<"Xd"; wyn=wyn+lastin.size()-sis+1+zc; zc=1; } } else { //cout<<n<<" "<<zc<<" f"; zc=zc+lastin.size()-in.size(); //cout<<lastin.size()<<" "<<in.size()<<endl; wyn+=zc; } } else if(in.size()==lastin.size()+zc && in<=lastin) { ++wyn; zc=1; } else { zc=0; } lastin=in; cout<<zc<<" "<<endl; } cout<<wyn; return 0; /* string a,b; while(1) {cin>>a>>b; if(a>b) { cout<<1; } else if(a<b) { cout<<0; } else if(a==b) { cout<<-1; } cout<<endl; }*/ } |