/ SeriousOJ /

Record Detail

Compile Error

foo.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

void solve(int cs) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> sf(n, 0);
  int cnt = 0;
  for (int i = n - 1; i; i--) {
    if (i + a[i] < n) {
      sf[i + a[i]]++;
      if (sf[i + a[i]] == 1) {
        cnt += 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << n - cnt << " \n"[i == n - 1];
    if (i < n - 1) {
      if (i + 1 + a[i + 1] < n) {
        sf[i + 1 + a[i + 1]]--;
        if (sf[i + 1 + a[i + 1]] == 0) {
          cnt -= 1;
        }
      }
    } 
    if (i + a[i] < n) {
      sf[i + a[i]]++;
      if (sf[i + a[i]] == 1) {
        cnt += 1;
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1066 Light switches
Contest
Brain Booster #4
Language
C99 (GCC 13.2.0)
Submit At
2024-07-14 18:24:35
Judged At
2024-10-03 13:35:16
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes