-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbee1266.cpp
More file actions
47 lines (36 loc) · 718 Bytes
/
Copy pathbee1266.cpp
File metadata and controls
47 lines (36 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Contest : Beecrowd
* Problem : Tornado!
* Link : https://judge.beecrowd.com/pt/problems/view/1266
* Time : O(N)
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
const int N = 5e3+1;
int n;
void solve() {
bitset<N> posts;
int start = 0;
for (int i = 0; i < n; ++i) {
int x; cin >> x;
if (x && !start) start = i;
posts[i] = x;
}
int cnt = 0, q = n, i = start;
while (q--) {
int pre = (i-1 + n) % n;
if (!posts[pre] && !posts[i]) {
posts[i] = 1;
cnt++;
}
i = (i+1) % n;
}
cout << cnt << '\n';
}
int main() {
fastio
while (cin >> n && n) solve();
return 0;
}