-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path100988_E_Flashlights.cpp
62 lines (51 loc) · 1.25 KB
/
100988_E_Flashlights.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
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <memory.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const int SN = 333;
char s[N];
bool a[N];
bool b[N][SN];
int main(){
//freopen("input.txt","r",stdin);// freopen("output.txt","w",stdout);
int n, m;
scanf("%d%s%d",&n,&s,&m);
int d;
for(d=1;(d+1)*(d+1)<=n;++d);
for(int i=0;i<n;++i) a[i] = s[i]-'0';
gets(s);
while(m--){
gets(s);
if(*s=='o'){
for(int i=0;i<n;++i){
for(int k=1;k<=d;++k) if(b[i][k]){
a[i]^=1;
b[i][k]=0;
if(i+k<n) b[i+k][k]^=1;
}
putchar(a[i]+'0');
}
puts("");
}else{
int i,j,k;
sscanf(s,"%d%d%d",&i,&j,&k);
--i;--j;
if(k>d) for(int x=i;x<=j;x+=k) a[x]^=1;
else{
j = i + ((j-i)/k)*k;
b[i][k]^=1;
if(j+k<n) b[j+k][k]^=1;
}
}
}
return 0;
}