Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. ///////////////////////////////////Pre-Written Code/////////////////////////////
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <vector>
  5. #include <queue>
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <stdlib.h>
  9. #include <math.h>
  10. #include <numeric>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <functional>
  15.  
  16. using namespace std;
  17. #define all(c) c.begin(),c.end()
  18. #define rep_(i,n) for(i=n-1;i>=0;i--)
  19. #define rep(i,n) for(i=0;i<n;i++)
  20. #define forr(i,a,b) for(i=a;i<=b;i++)
  21. #define forr_(i,a,b) for(i=a;i>=b;i--)
  22. #define min(a,b) ( a>b? b : a )
  23. #define max(a,b) ( a>b? a : b )
  24. #define sz size()
  25. #define pb(a) push_back(a)
  26. #define mset(a,v) memset(a,v,sizeof(a))
  27. #define f first
  28. #define s second
  29. #define EPS 1e-11
  30.  
  31. typedef vector<int> vi;
  32. typedef vector<vi> vvi;
  33. typedef map<int,int> mi;
  34. typedef vi::iterator it;
  35. typedef pair<int,int> pii;
  36. typedef vector<pii> vpii;
  37. typedef vector<string> vs;
  38. typedef pair<string,int> psi;
  39. typedef vector<psi> vpsi;
  40. typedef queue<int> qi;
  41. typedef queue<pii> qpii;
  42. typedef unsigned long long ubig;
  43. typedef long long big;
  44. typedef long double bigd;
  45. typedef stringstream ss;
  46. template<class T> string tos(T x){stringstream ss;  ss<<x; return ss.str();}
  47. void rot(vvi v,vvi& tmp,int r1,int c1,int r2,int c2)
  48. {
  49.     tmp.resize(c2-c1+1);
  50.     int i,j;
  51.     rep(i,tmp.sz)
  52.         tmp[i].resize(r2-r1+1);
  53.     forr(i,r1,r2)
  54.         forr(j,c1,c2)
  55.             tmp[j-c1][tmp[0].sz-(i-r1)-1]=v[i][j];
  56. }
  57. bool isPal(string s)
  58. {
  59.     int i=0,j=s.sz-1;
  60.     while(i<j)
  61.     {
  62.         if(islower(s[i]) && islower(s[j]) && s[i]!=s[j])
  63.             return false;
  64.         i++; j--;
  65.     }
  66.     return true;
  67. }
  68. ///////////////////////////////////Pre-Written Code/////////////////////////////
  69.  
  70. int vis[10000],n,m;
  71.  
  72. void solve(int box, int stp)
  73. {
  74.     while(box!=0 && box!=n+1)
  75.     {
  76.         vis[box]=true;
  77.         box+=stp;
  78.     }
  79. }
  80. void imp()
  81. {
  82.     cout<<"-1\n";
  83.     exit(0);
  84. }
  85. int main()
  86. {
  87.  
  88.     mset(vis,0);
  89.     int i,j;
  90.     cin>>n>>m;
  91.     string s,dir;
  92.     char c;
  93.     int box,stp;
  94.  
  95.     rep(i,m)
  96.     {
  97.         rep(j,3)cin>>dir;
  98.         cin>>s>>box;
  99.         if( dir=="left" )
  100.             stp=1;
  101.         else
  102.             stp=-1;
  103.         solve( box, stp );
  104.     }
  105.     int res=0;
  106.     forr(i,1,n)if( !vis[i] )res++;
  107.  
  108.     if( !res ) imp();
  109.  
  110.     cout<<res<<endl;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement