Submission #370069

# Submission time Handle Problem Language Result Execution time Memory
370069 2021-02-23T07:32:34 Z Mamnoon_Siam Long Mansion (JOI17_long_mansion) C++17
10 / 100
3000 ms 63340 KB
#include <bits/stdc++.h>
using namespace std;

/* sorry, this is the bare minimum :'( */
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second

int main(int argc, char const *argv[])
{
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  int n; cin >> n;
  vi C(n-1);
  for(int i = 0; i < n-1; ++i) {
    cin >> C[i];
    C[i]--;
  }
  using bs = bitset<5000>;
  vector<bs> A(n);
  for(int i = 0; i < n; ++i) {
    int k; cin >> k;
    while(k--) {
      int x; cin >> x;
      x--;
      A[i][x] = 1;
    }
  }
  vector<ii> ra(n);
  for(int i = 0; i < n; ++i) {
    int l = i, r = i;
    bs has = A[i];
    while(true) {
      int flag = 0;
      if(l and has[C[l-1]]) {
        has |= A[--l];
        ++flag;
      }
      if(r < n-1 and has[C[r]]) {
        has |= A[++r];
        ++flag;
      }
      if(!flag) break;
    }
    // cout << l+1 << ' ' << r+1 << endl;
    ra[i] = {l, r};
  }
  int q; cin >> q;
  while(q--) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    cout << (ra[x].fi <= y and y <= ra[x].se ? "YES" : "NO") << endl;
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1644 KB Output is correct
2 Correct 256 ms 2284 KB Output is correct
3 Correct 1202 ms 3676 KB Output is correct
4 Correct 22 ms 1644 KB Output is correct
5 Correct 335 ms 1824 KB Output is correct
6 Correct 70 ms 1772 KB Output is correct
7 Correct 80 ms 1772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1644 KB Output is correct
2 Correct 256 ms 2284 KB Output is correct
3 Correct 1202 ms 3676 KB Output is correct
4 Correct 22 ms 1644 KB Output is correct
5 Correct 335 ms 1824 KB Output is correct
6 Correct 70 ms 1772 KB Output is correct
7 Correct 80 ms 1772 KB Output is correct
8 Correct 1208 ms 7652 KB Output is correct
9 Correct 1167 ms 7640 KB Output is correct
10 Correct 1413 ms 8684 KB Output is correct
11 Correct 2350 ms 10092 KB Output is correct
12 Correct 1200 ms 6580 KB Output is correct
13 Correct 1234 ms 7780 KB Output is correct
14 Correct 1204 ms 7868 KB Output is correct
15 Correct 1351 ms 7660 KB Output is correct
16 Correct 1501 ms 7816 KB Output is correct
17 Correct 1177 ms 7888 KB Output is correct
18 Correct 1192 ms 7928 KB Output is correct
19 Correct 1208 ms 7972 KB Output is correct
20 Correct 1450 ms 8008 KB Output is correct
21 Correct 1525 ms 7784 KB Output is correct
22 Correct 1286 ms 7728 KB Output is correct
23 Correct 1250 ms 7660 KB Output is correct
24 Correct 1231 ms 7532 KB Output is correct
25 Correct 1239 ms 7788 KB Output is correct
26 Correct 1192 ms 7532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3085 ms 63340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1644 KB Output is correct
2 Correct 256 ms 2284 KB Output is correct
3 Correct 1202 ms 3676 KB Output is correct
4 Correct 22 ms 1644 KB Output is correct
5 Correct 335 ms 1824 KB Output is correct
6 Correct 70 ms 1772 KB Output is correct
7 Correct 80 ms 1772 KB Output is correct
8 Correct 1208 ms 7652 KB Output is correct
9 Correct 1167 ms 7640 KB Output is correct
10 Correct 1413 ms 8684 KB Output is correct
11 Correct 2350 ms 10092 KB Output is correct
12 Correct 1200 ms 6580 KB Output is correct
13 Correct 1234 ms 7780 KB Output is correct
14 Correct 1204 ms 7868 KB Output is correct
15 Correct 1351 ms 7660 KB Output is correct
16 Correct 1501 ms 7816 KB Output is correct
17 Correct 1177 ms 7888 KB Output is correct
18 Correct 1192 ms 7928 KB Output is correct
19 Correct 1208 ms 7972 KB Output is correct
20 Correct 1450 ms 8008 KB Output is correct
21 Correct 1525 ms 7784 KB Output is correct
22 Correct 1286 ms 7728 KB Output is correct
23 Correct 1250 ms 7660 KB Output is correct
24 Correct 1231 ms 7532 KB Output is correct
25 Correct 1239 ms 7788 KB Output is correct
26 Correct 1192 ms 7532 KB Output is correct
27 Execution timed out 3085 ms 63340 KB Time limit exceeded
28 Halted 0 ms 0 KB -