-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_1244.cpp
More file actions
57 lines (51 loc) · 1.06 KB
/
BOJ_1244.cpp
File metadata and controls
57 lines (51 loc) · 1.06 KB
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
48
49
50
51
52
53
54
55
56
57
// 22 / 2 / 5
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<int> arr;
int main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
arr.assign(n + 1, 0);
for (int i = 1; i <= n; i++)
cin >> arr[i];
int m;
cin >> m;
while (m--)
{
int gender, bulb;
cin >> gender >> bulb;
if (gender == 1)
{
for (int i = bulb; i <= n; i += bulb)
arr[i] = 1 - arr[i];
}
else
{
for (int j = 0; (bulb + j <= n) && (bulb - j >= 1); j++)
{
if (arr[bulb + j] != arr[bulb - j])
break;
arr[bulb + j] = 1 - arr[bulb + j];
if (j == 0)
continue;
arr[bulb - j] = 1 - arr[bulb - j];
}
}
}
int k = 0;
for (int i = 1; i <= n; i++)
{
cout << arr[i] << " ";
k++;
if (k == 20)
{
cout << "\n";
k = 0;
}
}
return 0;
}