fork download
  1. /*
  2.   Author: Aminul Islam.
  3.   Email: iaminul237@gmail.com
  4.   Facebook: www.facebook.com/aminul.islam116
  5.   Department: mathematics
  6.   Institution: Shahjalal university of science and technology, Sylhet.
  7.   Bangladesh.
  8. */
  9. #include<bits/stdc++.h>
  10. #define ll long long
  11. #define ull unsigned long long
  12. #define sll signed long long
  13. #define I() ( { int a ; read(a) ; a; } )
  14. #define L() ( { ll a ; read(a) ; a; } )
  15. #define D() ({double a; scanf("%lf", &a); a;})
  16. #define UL() ( { ull a; read(a); a; } )
  17. #define SL() ( { sll a; read(a); a; } )
  18.  
  19. ///Printing Methods
  20. #define print1(a) (printf("%I64d ", a))
  21. #define print1ln(a) (printf("%I64d\n", a))
  22. #define print2(a, b) (printf("%I64d %I64d ", a, b))
  23. #define print2ln(a, b) (printf("%I64d %I64d\n", a, b))
  24. #define print3ln(a, b, c) (printf("%I64d %I64d %I64d\n", a, b, c))
  25.  
  26. #define MAX 300005
  27.  
  28. template<class T>inline bool read(T &x){
  29. int c=getchar();int sgn=1;
  30. while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
  31. for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
  32. x*=sgn; return ~c;
  33. }
  34. using namespace std;
  35. int main(){
  36. int testCase = I();
  37. while(testCase--){
  38. int n = I(); double requiredTime = 0.0; map<string, double> words;
  39. while(n--){
  40. string temp; cin >> temp;
  41. if(words[temp] > 0.000000){
  42. requiredTime += words[temp]/2.0;
  43. //cout << words[temp] << " / 2.0 = " << words[temp]/2.000000 << endl;
  44. }
  45. else{
  46. bool left;
  47. for(int i = 0; i < temp.size(); i++){
  48. if(i == 0){
  49. requiredTime += 0.2;
  50. if(temp[i] == 'd' || temp[i] == 'f') left = true;
  51. else left = false;
  52. }
  53. else if(temp[i] == 'd' || temp[i] == 'f'){
  54. if(left) requiredTime += 0.4;
  55. else{
  56. requiredTime += 0.2;
  57. left = true;
  58. }
  59. }
  60. else{
  61. if(left){
  62. requiredTime += 0.2;
  63. left = false;
  64. }
  65. else requiredTime += 0.4;
  66. }
  67.  
  68. }
  69. words[temp] = requiredTime;
  70. }
  71.  
  72. }
  73. cout << (int)(requiredTime*10.0) << endl;
  74. }
  75.  
  76.  
  77. return 0;
  78. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty