Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int its(string s){
- int sum=0,it=0;
- for(int i=s.size()-1;i>=0;i--){
- double h=((double)s[i]-'0')*pow(10,it);
- sum+=h;
- cout<<sum<<endl;
- it++;
- }
- return sum;
- }
- /*bool compSize(string &s1, string &s2){
- if(s1.size()!=s2.size()) return s1.size()<s2.size();
- return s1<s2;
- }*/
- void reset(int (&abc)[27]){
- for(int i=0;i<27;i++){
- abc[i]=0;
- }
- }
- void letShow(int (&abc)[27]){
- for(int i=0;i<27;i++){
- char a(i+97);
- /*cout<<"["<<a<<"]: "<<abc[i]<<"||";
- if(i%5==0)
- cout<<"\n";*/
- }
- }
- char maxLet(int (&abc)[27]){
- char r='z';
- int val=0,pos=0;
- for(int i=26;i>=0;i--){
- if(abc[i]>=val){
- val=abc[i];
- pos=i;
- r=(i+97);
- }
- }
- abc[pos]=0;
- return r;
- }
- int main()
- {
- int let[27];
- string inp;
- int i=0,sol=0;
- while(getline(cin,inp)){
- i=0;
- bool realRoom=false;
- reset(let);
- while(inp[i]!='['){
- if(inp[i]!='-'){
- let[(int)inp[i]-97]+=1;
- //cout<<"IEE";
- }
- ++i;
- }
- string co,num;
- int code;
- char toplet[5];
- for(int i=0;i<5;i++){
- toplet[i]='z';
- }
- letShow(let);
- for(int i=0;i<5;i++){
- toplet[i]=maxLet(let);
- //cout<<"T:"<<toplet[i]<<endl;
- }
- letShow(let);
- co.assign(inp.end()-6 ,inp.end()-1);
- for(int i=0;i<5;i++){
- if(toplet[i]!=co[i]){
- i=5;
- realRoom=false;
- }
- else realRoom=true;
- }
- num.assign(inp.end()-10,inp.end()-7);
- code=its(num);
- if(realRoom){
- //cout<<"DAMN\n";
- sol+=code;
- //cout<<sol<<"@";
- }
- //cout<<"WE :"<<co<<" WE";
- letShow(let);
- cout<<"SOl: "<<sol<<"\n";
- }
- }
Add Comment
Please, Sign In to add comment