Submission #237781

# Submission time Handle Problem Language Result Execution time Memory
237781 2020-06-08T18:11:05 Z Haunted_Cpp Lasers (NOI19_lasers) C++17
41 / 100
949 ms 139384 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;

const int MAX_N = 1000000000 + 5;
const int ROOT = 0;
const int NODE = 5e6 + 5;

int L [NODE], R [NODE], Time = 0;

int seg [NODE];
short lazy [NODE];
 
int expandir (int delta) {
  if (~delta) return delta;
  return ++Time;
}
 
void push (int l, int r, int where) {
  if (lazy[where] == 0) return;

  if (l != r) {
    L[where] = expandir (L[where]);
    R[where] = expandir (R[where]);
    
    seg[L[where]] += lazy[where];
    seg[R[where]] += lazy[where];

    lazy[L[where]] += lazy[where];
    lazy[R[where]] += lazy[where];
  }
  lazy[where] = 0;
}

void modify (int l, int r, int where, int ql, int qr) {
  if (l > qr || r < ql) return;
  if (l >= ql && r <= qr) {
    ++seg[where];
    ++lazy[where];
    return;
  }
  const int mid = l + (r - l) / 2;
  push (l, r, where);
  if (mid >= ql) {
    L[where] = expandir (L[where]);
    modify (l, mid, L[where], ql, qr);
  }
  if (mid + 1 <= qr) {
    R[where] = expandir (R[where]);
    modify (mid + 1, r, R[where], ql, qr);
  }
  seg[where] = (~L[where] ? seg[L[where]] : 0) + (~R[where] ? seg[R[where]] : 0);
}

int res = 0, goal;

void solve (int l, int r, int where) {
  if (where == -1) {
    res += (r - l + 1);
    return;
  }
  if (l == r) {
    res += (seg[where] != goal);
    return;
  }
  const int mid = l + (r - l) / 2;
  push (l, r, where);
  solve (l, mid, L[where]);
  solve (mid + 1, r, R[where]);
}
 
int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int l, r;
  cin >> l >> r;
  goal = r;
  for (int i = 0; i < NODE; i++) {
    L[i] = R[i] = -1;
    seg[i] = 0;
    lazy[i] = 0;
  }
  for (int T = 0; T < r; T++) {
    int qts;
    cin >> qts;
    int s = 0;
    vector<int> arr (qts);
    for (int i = 0; i < qts; i++) {
      cin >> arr[i];
      s += arr[i];
    }
    int cur = 0;
    int mn = 0;
    int st, et;
    for (int i = 0; i < qts; i++) {
      st = max (mn, cur);
      et = l - s - 1;
      modify (0, l - 1, ROOT, st, et);
      mn = max (mn, l - s);
      cur += arr[i];
      s -= arr[i];
    } 
    st = max (mn, cur);
    et = l - s - 1;
    modify (0, l - 1, ROOT, st, et);
  };
  solve (0, l - 1, ROOT);
  cout << res << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 163 ms 139384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 163 ms 139384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 138 ms 69504 KB Output is correct
2 Correct 80 ms 69112 KB Output is correct
3 Correct 92 ms 69036 KB Output is correct
4 Correct 141 ms 69504 KB Output is correct
5 Correct 100 ms 69368 KB Output is correct
6 Correct 167 ms 70136 KB Output is correct
7 Correct 55 ms 68856 KB Output is correct
8 Correct 167 ms 69844 KB Output is correct
9 Correct 100 ms 69240 KB Output is correct
10 Correct 148 ms 69556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 68856 KB Output is correct
2 Correct 42 ms 68856 KB Output is correct
3 Correct 48 ms 68856 KB Output is correct
4 Correct 45 ms 68856 KB Output is correct
5 Correct 43 ms 68856 KB Output is correct
6 Correct 42 ms 68856 KB Output is correct
7 Correct 50 ms 68856 KB Output is correct
8 Correct 43 ms 68856 KB Output is correct
9 Correct 43 ms 68856 KB Output is correct
10 Correct 48 ms 68856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 69504 KB Output is correct
2 Correct 80 ms 69112 KB Output is correct
3 Correct 92 ms 69036 KB Output is correct
4 Correct 141 ms 69504 KB Output is correct
5 Correct 100 ms 69368 KB Output is correct
6 Correct 167 ms 70136 KB Output is correct
7 Correct 55 ms 68856 KB Output is correct
8 Correct 167 ms 69844 KB Output is correct
9 Correct 100 ms 69240 KB Output is correct
10 Correct 148 ms 69556 KB Output is correct
11 Correct 43 ms 68856 KB Output is correct
12 Correct 42 ms 68856 KB Output is correct
13 Correct 48 ms 68856 KB Output is correct
14 Correct 45 ms 68856 KB Output is correct
15 Correct 43 ms 68856 KB Output is correct
16 Correct 42 ms 68856 KB Output is correct
17 Correct 50 ms 68856 KB Output is correct
18 Correct 43 ms 68856 KB Output is correct
19 Correct 43 ms 68856 KB Output is correct
20 Correct 48 ms 68856 KB Output is correct
21 Incorrect 949 ms 68856 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 163 ms 139384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -