fork download
  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <deque>
  6. #include <stack>
  7. #include <bitset>
  8. #include <algorithm>
  9. #include <functional>
  10. #include <numeric>
  11. #include <utility>
  12. #include <sstream>
  13. #include <iostream>
  14. #include <iomanip>
  15. #include <cstdio>
  16. #include <cmath>
  17. #include <cstdlib>
  18. #include <ctime>
  19.  
  20. using namespace std;
  21.  
  22. class BearFair {
  23. public:
  24. vector < pair < int , int > > Arr;
  25. string isFair(int, int, vector <int>, vector <int>);
  26. };
  27.  
  28. bool dp[51][501][501];
  29.  
  30.  
  31. string BearFair::isFair(int n, int b, vector <int> upTo, vector <int> quantity)
  32. {
  33.  
  34. int i,j,k,l;
  35. Arr.push_back(make_pair(0,0));
  36. for(i=0;i<(int)upTo.size();++i)
  37. Arr.push_back(make_pair(upTo[i],quantity[i]));
  38. sort(Arr.begin(),Arr.end());
  39. dp[0][0][0]=1;
  40. int even , odd , pre = 0 ;
  41. for(i=1;i<(int)Arr.size();++i)
  42. {
  43. Arr[i].second-=pre;
  44. pre+=Arr[i].second;
  45. even = (Arr[i].first-Arr[i-1].first)/2 + ((Arr[i].first-Arr[i-1].first)%2 && Arr[i].first%2 ==0); // No of Most Even choices he can make at the i th segment
  46. odd = Arr[i].first-Arr[i-1].first - even; // Number of Most Odd choices he can make
  47. even = min(even,Arr[i].second);
  48. odd = min(odd,Arr[i].second);
  49. for(j=0;j<=n/2;++j)
  50. {
  51. for(k=0;k<=n/2;++k)
  52. {
  53. dp[i][j][k]=0;
  54. for(l=0;l<=min(even,j);++l)
  55. if(k-(Arr[i].second-l)>=0)
  56. dp[i][j][k]|=(Arr[i].second-l<=odd)*dp[i-1][j-l][k-(Arr[i].second-l)];
  57. }
  58. }
  59. }
  60.  
  61. if(dp[Arr.size()-1][n/2][n/2] )
  62. return "fair";
  63. else
  64. return "unfair";
  65.  
  66. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/5/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty