Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.29 KB | None | 0 0
  1. //bydlokod!!! yeeeah! try'a doubt, dude=)
  2. //shit code!! nevertheless, it works! olololololo Onotole is watching!
  3. //FREEDOM EQUALITY UPYACKA
  4. //E=m*C^2
  5. //dirty boys
  6. #pragma comment(linker, "/STACK:5000000")
  7. #define _CRT_SECURE_NO_WARNINGS
  8. #include <cstdio>
  9. #include <ctime>
  10. #include <cstdlib>
  11. #include <iostream>
  12. #include <algorithm>
  13. #include <cmath>
  14. #include <set>
  15. #include <vector>
  16. #include <stack>
  17. #include <fstream>
  18. #include <string>
  19. #include <cstring>
  20. #include <queue>
  21. #include <utility>
  22. using namespace std;
  23.  
  24. double const PI=2*asin(1.0);
  25. long long const INF=~(1<<31);
  26. double const EPS=0.000000001;
  27. long long const SUP=-INF-1;
  28. long long const BASE=6;
  29.  
  30. #define PB push_back
  31. #define sqr(x) (x)*(x)
  32.  
  33. vector<int> to_vector(long long n){
  34.     long long k=n;
  35.     vector<int> ans;
  36.     while(k != 0){
  37.         ans.push_back(k%10);
  38.         k/=10;
  39.     }
  40.     reverse(ans.begin(),ans.end());
  41.     return ans;
  42. }
  43.  
  44. long long to_int(vector<int> a){
  45.     long long ans=0;
  46.     for(int i=0;i<a.size();i++){
  47.         ans=ans*10+a[i];
  48.     }
  49.     return ans;
  50. }
  51.  
  52. long long perm(long long n,long long l,long long r){
  53.     vector<int> ans;
  54.     long long cnt=0,u,k=n;
  55.    
  56.     while(k != 0){
  57.         ans.push_back(k%10);
  58.         k/=10;
  59.     }
  60.  
  61.     sort(ans.begin(),ans.end());
  62.  
  63.     u=to_int(ans);
  64.     if(u <= r && u >= l && ans[0] != 0) cnt++;
  65.  
  66.     while(next_permutation(ans.begin(),ans.end())){
  67.         u=to_int(ans);
  68.         if(u <= r && u >= l && ans[0] != 0) cnt++;
  69.     }
  70.  
  71.     return (cnt == 2 )?1:0;
  72. }
  73. int cnt=0;
  74. vector<string> voc;
  75. string grab(vector<pair<string,string> > a){
  76.     string ans;
  77.     for(int i=0;i<a.size();i++){
  78.         ans+=a[i].second;
  79.         ans+=' ';
  80.     }
  81.  
  82.     ans[ans.length()-1]='.';
  83.     return ans;
  84. }
  85. void parse(string buf){
  86.     string a=buf,tmp;
  87.     int l=a.size();
  88.     int k,j;
  89.     transform(a.begin(),a.end(),a.begin(),::tolower);
  90.    
  91.     vector<pair<string,string> > ovo;
  92.     string tmp1,tmp2;
  93.     for(int i=0;i<a.size();i++){
  94.         if(a[i] == ' '){ ovo.push_back(make_pair(tmp1,tmp2)); tmp1.clear(); tmp2.clear();  continue;}
  95.         tmp1+=a[i];
  96.         tmp2+=buf[i];
  97.     }
  98.     tmp1.erase(tmp1.length()-1);
  99.     tmp2.erase(tmp2.length()-1);
  100.     ovo.push_back(make_pair(tmp1,tmp2));
  101.     l=ovo.size();
  102.     for(int i=0;i<l-1;i++){
  103.  
  104.         if(ovo[i].first == "is" ){
  105.             tmp1=ovo[i+1].first;
  106.             tmp2=ovo[i+1].second;
  107.  
  108.             if(tmp1 == "a" || tmp1== "the")
  109.                 ovo[i+1].second = "no";
  110.             else
  111.                 ovo.insert(ovo.begin()+i+1,make_pair("no","no"));  
  112.  
  113.             voc.push_back(grab(ovo));
  114.  
  115.             if(tmp1 == "a" || tmp1== "the")
  116.                 ovo[i+1].second = "no";
  117.             else
  118.                 ovo.erase(ovo.begin()+i+1);
  119.  
  120.             ovo[i+1].first = tmp1;
  121.             ovo[i+1].second = tmp2;
  122.         }
  123.  
  124.         if(ovo[i].first == "are" ){
  125.             tmp1=ovo[i+1].first;
  126.             tmp2=ovo[i+1].second;
  127.  
  128.             if(tmp1 == "a" || tmp1== "the")
  129.                 ovo[i+1].second = "no";
  130.             else
  131.                 ovo.insert(ovo.begin()+i+1,make_pair("no","no"));  
  132.  
  133.             voc.push_back(grab(ovo));
  134.  
  135.             if(tmp1 == "a" || tmp1== "the")
  136.                 ovo[i+1].second = "no";
  137.             else
  138.                 ovo.erase(ovo.begin()+i+1);        
  139.  
  140.             ovo[i+1].first = tmp1;
  141.             ovo[i+1].second = tmp2;
  142.         }
  143.  
  144.         if(ovo[i].first == "can"  || ovo[i].first == "must" || ovo[i].first == "may"  || ovo[i].first == "should" ){           
  145.             ovo.insert(ovo.begin()+i+1,make_pair("not","not"));
  146.             voc.push_back(grab(ovo));
  147.             ovo.erase(ovo.begin()+i+1);        
  148.         }
  149.  
  150.     }
  151.  
  152. int i=l-1;
  153.     if(ovo[i].first == "is" ){
  154.        
  155.  
  156.            
  157.                 ovo.insert(ovo.begin()+i+1,make_pair("no","no"));  
  158.  
  159.             voc.push_back(grab(ovo));
  160.  
  161.            
  162.                 ovo.erase(ovo.begin()+i+1);
  163.  
  164.            
  165.         }
  166.  
  167.         if(ovo[i].first == "are" ){
  168.            
  169.  
  170.                 ovo.insert(ovo.begin()+i+1,make_pair("no","no"));  
  171.  
  172.             voc.push_back(grab(ovo));
  173.  
  174.            
  175.                 ovo.erase(ovo.begin()+i+1);        
  176.  
  177.        
  178.         }
  179.  
  180.         if(ovo[i].first == "can"  || ovo[i].first == "must" || ovo[i].first == "may"  || ovo[i].first == "should" ){           
  181.             ovo.insert(ovo.begin()+i+1,make_pair("not","not"));
  182.             voc.push_back(grab(ovo));
  183.             ovo.erase(ovo.begin()+i+1);        
  184.         }
  185.    
  186. }
  187. string trim(string s1){
  188.     string s=s1;
  189.     while(s[s.length()-1] == ' ') s.erase(s.end()-1);
  190.     while(s[0] == ' ') s.erase(s.begin());
  191.     return s;
  192. }
  193. int main(){
  194.     freopen("m.in","r",stdin);freopen("m.out","w",stdout);
  195.     //freopen("input.txt","r",stdin);
  196.     //freopen("output.txt","w",stdout);
  197.     //ofstream cout ("output.txt");
  198.     string s;
  199.     char c=90,l=90;
  200.     while(c > 10){
  201.         if(l=='.') l=getchar();
  202.         c=getchar();       
  203.         if(l=='.' && c != ' ') break;
  204.        
  205.         s+=c;
  206.  
  207.         if(c == '.'){
  208.             parse(s);
  209.             //puts(s.c_str());
  210.             s.clear();
  211.         }
  212.  
  213.         l=c;
  214.     }
  215.     printf("%d\n",voc.size());
  216.     for(int i=0;i<voc.size();i++)
  217.         puts(trim(voc[i]).c_str());
  218.     return 0;
  219. }
  220. //Одобрено Сумским Обласным Раввинатом. Кошерно.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement