prestige

Untitled

Jun 19th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #include <algorithm>
  2. #include <bitset>
  3. #include <cassert>
  4. #include <cmath>
  5. #include <cstdio>
  6. #include <cstdlib>
  7. #include <cstring>
  8. #include <iostream>
  9. #include <list>
  10. #include <map>
  11. #include <queue>
  12. #include <set>
  13. #include <string>
  14. #include <sstream>
  15. #include <vector>
  16. #include <complex>
  17. #include <ctime>
  18. #include <stack>
  19.  
  20. using namespace std;
  21.  
  22. typedef long long ll;
  23. typedef unsigned long long ull;
  24. typedef vector<int> VI;
  25. typedef vector< VI > VVI;
  26. typedef pair<int, int> PII;
  27. typedef vector<PII> VPII;
  28.  
  29. #define REP(i, n) for(int i = 0; i < n; ++i)
  30. #define RREP(i, n) for(int i = n - 1; i >= 0; --i)
  31. #define FOR(i, x, y) for(int i = x; i <= y; ++i)
  32. #define RFOR(i, x, y) for(int i = x; i >= y; --i)
  33. #define SZ(a) (int)(a).size()
  34. #define ALL(a) (a).begin(),(a).end()
  35. #define SORT(a) sort(ALL(a))
  36. #define CLEAR(x) memset(x, 0, sizeof x);
  37. #define COPY(FROM, TO) memcpy(TO, FROM, sizeof TO);
  38. #define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
  39. #define pb push_back
  40. #define sqr(x) (x)*(x)
  41. #define X first
  42. #define Y second
  43. const long double pi=acos(-1.0);
  44. const long double eps = 1e-9;
  45.  
  46. int n;
  47. int m;
  48. int k;
  49. VI a;
  50. set<pair<int, int> > s[21];
  51. int main () {
  52. cin >> n;
  53. REP (i, n) {
  54. int t;
  55. cin >> t;
  56. a.pb(t);
  57. REP (j, 21) {
  58. if ((1<<j) & t) {
  59. s[j].insert(i, t);
  60. }
  61. }
  62. }
  63. set<int> ans;
  64. REP (i, n) {
  65. ans.insert(a[i]);
  66. set<pair<int, int> > loc;
  67. REP (j, 21) {
  68. set<pair<int, int> >::iterator it = s[j].lower_bound(make_pair(i, (a[i])));
  69. if (it != s[j].end()) {
  70. if (*it != make_pair(i, a[i])) {
  71. loc.insert(make_pair((it->second), j));
  72. }
  73. }
  74. }
  75. for (set<pair<int, int> >::iterator it = loc.begin(); it != loc.end(); it++) {
  76. ans.insert(a[i] | (it->first));
  77. }
  78. }
  79. cout << ans.size();
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment