| /*** | |
| Md. Nazmul Hasan | |
| Shahjalal University of Science & Technology,Sylhet. | |
| hasan08sust@gmail.com | |
| ***/ | |
| #include<iostream> | |
| #include<cstdio> | |
| #include<stack> | |
| #include<queue> | |
| #include<map> | |
| #include<vector> | |
| #include<algorithm> | |
| #include<cstring> | |
| #include<sstream> | |
| #include<cmath> | |
| #include <iomanip> | |
| using namespace std ; | |
| typedef long long ll ; | |
| typedef int in ; | |
| typedef unsigned long long ull ; | |
| const double pi = 2*acos(0) ; | |
| #define maxi 40000 | |
| #define pf printf | |
| #define sc scanf | |
| #define pb push_back | |
| #define MEM(x,y) (memset((x),(y),sizeof(x))) | |
| #define MIN(x,y) ((x) < (y) ? (x) : (y)) | |
| #define MAX(x,y) ((x) > (y) ? (x) : (y)) | |
| #define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ; | |
| #define new_line pf("\n") | |
| #define clear_data(array) memset(array,0,sizeof(array)) | |
| #define highest_int 2147483647 | |
| int main() | |
| { | |
| int test,in,b,u,s,t,m,p,f,sum,as,ds,cnt; | |
| int data[10001]; | |
| sc("%d",&test); | |
| getchar(); | |
| string str; | |
| while(test--){ | |
| getline(cin,str); | |
| in =0; | |
| b=0; | |
| u=0; | |
| s=0; | |
| p=0; | |
| f=0; | |
| t=0; | |
| m=0; | |
| sum=0; | |
| for(int i=0 ; i<str.size() ; i++){ | |
| if(str[i]=='B'){ | |
| data[in++] = 1; | |
| sum += 1; | |
| b++; | |
| }else if(str[i]=='U'){ | |
| data[in++] = 2; | |
| sum += 10; | |
| u++; | |
| }else if(str[i]=='S'){ | |
| data[in++] = 3; | |
| sum += 100; | |
| s++; | |
| }else if(str[i]=='P'){ | |
| data[in++] = 4; | |
| sum += 1000; | |
| p++; | |
| }else if(str[i]=='F'){ | |
| data[in++] = 5; | |
| sum += 10000; | |
| f++; | |
| }else if(str[i]=='T'){ | |
| data[in++] = 6; | |
| sum += 100000; | |
| t++; | |
| }else if(str[i]=='M'){ | |
| data[in++] = 7; | |
| sum += 1000000; | |
| m++; | |
| } | |
| } | |
| as=0; | |
| ds=0; | |
| for(int i=0 ; i<in-1 ; i++){ | |
| if(data[i]>data[i+1]) | |
| ds++; | |
| else if(data[i]<data[i+1]) | |
| as++; | |
| } | |
| cnt=0 ; | |
| if(as>0 || (as==0 && ds==0)){ | |
| for(int j=0 ; j<in-1 ; j++){ | |
| if(data[j]>data[j+1]) | |
| cnt++; | |
| } | |
| }else if(ds>0){ | |
| for(int j=0 ; j<in-1 ; j++){ | |
| if(data[j]<data[j+1]) | |
| cnt++; | |
| } | |
| } | |
| if(cnt>0 ||b>9||u>9||s>9||p>9||f>9||t>9||m>9){ | |
| pf("error\n"); | |
| }else{ | |
| pf("%d\n",sum); | |
| } | |
| str.clear(); | |
| } | |
| return 0; | |
| } |
21 October 2017
UVA 11787 (Numeral Hieroglyphs)
Subscribe to:
Post Comments (Atom)
-
/*** Md. Namzul Hasan Shahjalal University of Science & Technology,Sylhet. hasan08sust@gmail.com ***/ #include<bits/stdc++.h...
No comments:
Post a Comment