fork download
  1. // In the name of God
  2. #include <iostream>
  3. #include <cmath>
  4. #include <cstdio>
  5. #include <cstring>
  6. #include <algorithm>
  7. #include <iomanip>
  8. #include <ctime>
  9. #include <queue>
  10. #include <set>
  11. #include <map>
  12. #include <vector>
  13. #include <list>
  14. #include <assert.h>
  15. #include <bitset>
  16. #define sqr(a) (a)*(a)
  17. #define all(a) (a).begin(), (a).end()
  18. using namespace std;
  19.  
  20. template <typename T>
  21. T next_int() {
  22. T x = 0, p = 1;
  23. char ch;
  24. do { ch = getchar(); } while(ch <= ' ');
  25. if(ch == '-') {
  26. p = -1;
  27. ch = getchar();
  28. }
  29. while(ch >= '0' && ch <= '9') {
  30. x = x * 10 + (ch - '0');
  31. ch = getchar();
  32. }
  33. return p * x;
  34. }
  35.  
  36. string next_token() {
  37. char ch;
  38. string ans = "";
  39. do { ch = getchar(); } while(ch <= ' ');
  40. while((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
  41. ans += ch;
  42. ch = getchar();
  43. }
  44. return ans;
  45. }
  46.  
  47. const long long INF = (long long)1e18;
  48. const int INFINT = (int)1e9 + 227 + 1;
  49. const int MOD = (int)1e9 + 7;
  50. const long double EPS = 1e-9;
  51.  
  52. const int MAXM = (int)1e5 + 227 + 1;
  53.  
  54. int t[MAXM * 4];
  55.  
  56. void modi(int v, int l, int r, int p, int a) {
  57. if(l == r) {
  58. t[v] = a;
  59. return;
  60. }
  61.  
  62. int mid = (l + r) / 2;
  63. if(p <= mid)
  64. modi(v * 2, l, mid, p, a);
  65. else
  66. modi(v * 2 + 1, mid + 1, r, p, a);
  67.  
  68. t[v] = min(t[v * 2], t[v * 2 + 1]);
  69. }
  70.  
  71. void add(int a, int times) {
  72. modi(1, 1, MAXM, a + 1, times);
  73. }
  74.  
  75. int get(int v, int l, int r, int _l) {
  76. if(l == r) return l - 1;
  77.  
  78. int mid = (l + r) / 2;
  79. if(t[v * 2] < _l)
  80. return get(v * 2, l, mid, _l);
  81. return get(v * 2 + 1, mid + 1, r, _l);
  82. }
  83.  
  84. void init() {
  85. for(int i = 0; i < MAXM * 4; i++)
  86. t[i] = -(int)1e9;
  87. }
  88.  
  89. int main() {
  90. init();
  91. int n;
  92. freopen("input.txt", "r", stdin);
  93. scanf("%d", &n);
  94.  
  95. add(0, 0);
  96.  
  97. int res = 0;
  98. for (int i = 1; i < n; i++) {
  99. int c, a;
  100. scanf("%d %d", &c, &a);
  101.  
  102. int mex = get(1, 1, MAXM, i - c);
  103. if (a % 2)
  104. res ^= mex;
  105.  
  106. add(mex, i);
  107. }
  108. if (res == 0)
  109. cout << "Second";
  110. else
  111. cout << "First";
  112. // cout << res;
  113. }
Time limit exceeded #stdin #stdout 5s 5032KB
stdin
Standard input is empty
stdout
Standard output is empty