-
Notifications
You must be signed in to change notification settings - Fork 1
/
1244.cpp
70 lines (57 loc) · 1.51 KB
/
1244.cpp
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
62
63
64
65
66
67
68
69
70
#include <iostream>
#include <vector>
using namespace std;
vector<int> swich;
vector<pair<int,int>> v;
void divide(int n, int k) {
for (int i = 0; i < k; i++) {
if (v[i].first == 1) {
for (int j = 1; j <= n; j++) {
if (v[i].second * j > n)
break;
if (v[i].second * j <= n) {
swich[v[i].second * j] = !swich[v[i].second * j];
}
}
}
else{
swich[v[i].second] = !swich[v[i].second];
for(int j=1;j<=n;j++){
if(v[i].second-j >=1 && v[i].second+j <=n)
{
if (swich[v[i].second - j] == swich[v[i].second + j])//
{
swich[v[i].second - j] = !swich[v[i].second - j];
swich[v[i].second + j] = !swich[v[i].second + j];
} else
break;
}
}
}
}
}
int main() {
int n,k;
//입력
cin >> n; //스위치 갯수
swich.assign(n+1, 0);
for (int i = 1; i <= n; i++) {
cin >> swich[i];
}
cin >> k; //학생수
v.assign(k,{0,0});
for (int i = 0; i < k; i++) {
cin >> v[i].first >> v[i].second;
}
divide(n, k);
// for (int i = 1; i <= n; i++) {
// cout << i << swich[i] << "\n";
// }
//출력
for (int i = 1; i <= n; i++)
{ cout << swich[i] << " ";
if(i>=20 && i%20==0)
cout << "\n";
}
return 0;
}