Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None
  1. // Pre_code
  2.  
  3. //#include <bits/stdc++.h>
  4.  
  5. // header file
  6.  
  7. #include <sstream>
  8. #include <queue>
  9. #include <stack>
  10. #include <set>
  11. #include <map>
  12. #include <cstdio>
  13. #include <cstdlib>
  14. #include <cctype>
  15. #include <complex>
  16. #include <cmath>
  17. #include <iostream>
  18. #include <iomanip>
  19. #include <string>
  20. #include <utility>
  21. #include <vector>
  22. #include <algorithm>
  23. #include <bitset>
  24. #include <list>
  25. #include <string.h>
  26. #include <assert.h>
  27. #include <time.h>
  28. #include <fstream>
  29. #include <numeric>
  30. #include <cstring>
  31.  
  32. using namespace std ;
  33.  
  34. //define function
  35.  
  36. #pragma comment(linker, "/STACK:667772160")
  37. #define forln(i,a,n) for(int i=a ; i<n ; i++)
  38. #define foren(i,a,n) for(int i=a ; i<=n ; i++)
  39. #define forg0(i,a,n) for(int i=a ; i>n ; i--)
  40. #define fore0(i,a,n) for(int i=a ; i>=n ; i--)
  41. #define pb push_back
  42. #define pp pop_back
  43. #define clr(a,b) memset(a,b,sizeof(a))
  44. #define sf1(a) scanf("%d",&a)
  45. #define sf2(a,b) scanf("%d %d",&a,&b)
  46. #define sf1ll(a) scanf("%lld",&a)
  47. #define sf2ll(a,b) scanf("%lld %lld",&a,&b)
  48. #define pii acos(-1.0)
  49. #define jora_int pair<int,int>
  50. #define jora_ll pair<long long,long long>
  51. #define max3(a,b,c) max(a,max(b,c))
  52. #define min3(a,b,c) min(a,min(b,c))
  53. #define Max 1000000000000
  54. #define sz 500000+7
  55. #define Mod 1000000009
  56. #define EPS 1e-6
  57. #define ll long long
  58. #define ull unsigned long long
  59. #define fs first
  60. #define sc second
  61. #define wait system("pause")
  62. #define sf scanf
  63. #define pf printf
  64. #define mp make_pair
  65. #define ps pf("PASS\n")
  66. #define Read freopen("C:\\Users\\RONIN-47\\Desktop\\input_output\\input.txt","r",stdin)
  67. #define Write freopen("C:\\Users\\RONIN-47\\Desktop\\input_output\\output.txt","w",stdout)
  68. #define jora_double pair<double,double>
  69. //debug
  70.  
  71. template<class T1> void deb(T1 e1)
  72. {
  73. cout<<e1<<endl;
  74. }
  75. template<class T1,class T2> void deb(T1 e1,T2 e2)
  76. {
  77. cout<<e1<<" "<<e2<<endl;
  78. }
  79. template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3)
  80. {
  81. cout<<e1<<" "<<e2<<" "<<e3<<endl;
  82. }
  83. template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4)
  84. {
  85. cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
  86. }
  87. template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)
  88. {
  89. cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
  90. }
  91. template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6)
  92. {
  93. cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
  94. }
  95.  
  96. // moves
  97.  
  98. //int dx[]= {-1,-1,0,0,1,1};
  99. //int dy[]= {-1,0,-1,1,0,1};
  100. //int dx[]= {0,1,0,-1};/*4 side move*/
  101. //int dy[]= {1,0,-1,0};/*4 side move*/
  102. //int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
  103. //int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
  104. //int dx[]= {1,1,2,2,-1,-1,-2,-2}; /*night move*/
  105. //int dy[]= {2,-2,1,-1,2,-2,1,-1}; /*night move*/
  106.  
  107. //close
  108.  
  109. map<string,int>mymap ;
  110. int level[8000+7] ;
  111. int arr[sz] , flevel[8000+7] ;
  112.  
  113. int main()
  114. {
  115. // for(int i=33 ; i<=122 ; i++)
  116. // pf("%c\n",i);
  117. //
  118. // wait;
  119.  
  120. char ch ;
  121. string st ;
  122. st.clear();
  123. int cont = 0 , a , b , word_length = 0 , pl = 1 ;
  124.  
  125. while(ch = getchar())
  126. {
  127. if(pl%4 == 0 or ch == '\n')
  128. {
  129. word_length++;
  130. a = mymap[st] ;
  131.  
  132. if(!a)
  133. {
  134. mymap[st] = ++cont ;
  135. level[cont]++;
  136. }
  137.  
  138. else
  139. level[a]++;
  140.  
  141. st.clear();
  142.  
  143. if(ch == '\n')
  144. break;
  145. }
  146.  
  147. else
  148. st += ch ;
  149.  
  150. pl++;
  151. }
  152.  
  153. b = 1 ;
  154. pl = 1 ;
  155.  
  156. while(ch = getchar())
  157. {
  158. if(pl%4 == 0 or ch == '\n')
  159. {
  160. a = mymap[st] ;
  161. arr[b++] = a ;
  162. st.clear();
  163.  
  164. if(ch == '\n')
  165. break;
  166. }
  167.  
  168. else
  169. st += ch ;
  170.  
  171. pl++;
  172. }
  173.  
  174. int i=1 , j=1 , temp = 0 , ans = 0 , wd = 0 ;
  175.  
  176. while(i<b)
  177. {
  178. temp++;
  179. flevel[arr[i]]++;
  180.  
  181. if(flevel[arr[i]] == level[arr[i]])
  182. wd++;
  183.  
  184. if(temp == word_length and wd == cont)
  185. ans++;
  186.  
  187. while(temp>=word_length)
  188. {
  189. flevel[arr[j]]--;
  190. temp--;
  191.  
  192. if(flevel[arr[j]]<level[arr[j]])
  193. wd--;
  194. j++;
  195. }
  196. i++;
  197. }
  198.  
  199. deb(ans);
  200.  
  201. return 0;
  202. }
Advertisement
RAW Paste Data Copied
Advertisement