-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathN1244.cpp
More file actions
61 lines (49 loc) · 1.21 KB
/
Copy pathN1244.cpp
File metadata and controls
61 lines (49 loc) · 1.21 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
58
59
60
61
#include <iostream>
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
#define MAX 101
int count_switch,count_people,gender,number;
int s[MAX];
void male(int* arr, int n) {
for (int i = n; i <= count_switch; i += n) {
arr[i] = arr[i] == 1 ? 0 : 1;
}
}
void female(int* arr, int n) {
arr[n] = arr[n] == 1 ? 0 : 1;
int left = n - 1, right = n + 1;
while (arr[left] == arr[right]) {
if (left == 0 || right == count_switch+1 ) {
return;
}
arr[left] = arr[left] == 1 ? 0 : 1;
arr[right] = arr[right] == 1 ? 0 : 1;
left--;
right++;
}
}
int main() {
FASTIO;
cin >> count_switch;
for (int i = 1; i <= count_switch; i++) {
cin >> s[i];
}
cin >> count_people;
for (int i = 0; i < count_people; i++) {
cin >> gender >> number;
if (gender == 1) {
male(s,number);
}
else if (gender == 2) {
female(s, number);
}
}
const int perline = 20;
for (int i = 1; i <= count_switch; i++) {
cout << s[i] << " ";
if (i % perline == 0) {
cout << endl;
}
}
return 0;
}