#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<int, pair<int,int> > piii;
typedef pair<pair<ll,ll> ,pair<ll, ll> > plll;
typedef vector <ll> vi;
#define forw(i,a,b) for (ll i=a;i<=(b);i++)
#define forb(i,a,b) for (ll i=a;i>=(b);i--)
#define fastIO {ios::sync_with_stdio(false); cin.tie(0); }
#define fi first
#define se second
#define pu push
#define puf push_front
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fr front
#define all(a) a.begin(),a.end()
const ll oo=1e18;
const ll mod=1e9+7;
const int base=31;
const ll maxN=3e5+5;
const int tx[4]={0,1,0,-1};
const int ty[4]={1,0,-1,0};
const ll maxM=maxN*4+5;
const ll block=500;
#define mul(a,b) (a*b)%mod
#define add(a,b) (a+b)%mod
ll pre[maxN],n,key,q;
string s1,s2,s3,s4;
struct segment
{
vector <ll> seg,lazy;
segment(int n)
{
seg.assign(4*n+5,0);
lazy.assign(4*n+5,0);
}
ll get_pre(int l, int r)
{
ll ans=pre[r];
if (l>0) ans=(ans-pre[l-1]+mod)%mod;
return ans;
}
void down(int id, int l, int r, int mid)
{
if (!lazy[id]) return;
seg[id*2]=mul(get_pre(l-1,mid-1),lazy[id]);
lazy[id*2]=lazy[id];
seg[id*2+1]=mul(get_pre(mid,r-1),lazy[id]);
lazy[id*2+1]=lazy[id];
lazy[id]=0;
return;
}
void update(int id, int l, int r, int u, int v, ll val)
{
if (v<l || r<u) return;
if (u<=l && r<=v)
{
seg[id]=mul(get_pre(l-1,r-1),val);
lazy[id]=val;
return;
}
int mid=(l+r)/2;
down(id,l,r,mid);
update(id*2,l,mid,u,v,val);
update(id*2+1,mid+1,r,u,v,val);
seg[id]=add(seg[id*2],seg[id*2+1]);
return;
}
};
ll get(char c)
{
if (c=='J') return 1;
if (c=='O') return 2;
return 3;
}
void solve()
{
cin>>n;
cin>>s1>>s2>>s3;
cin>>q;
cin>>s4;
ll tmp=1;
//power[0]=1;
pre[0]=1;
segment seg(n);
forw(i,1,n)
{
//power[i]=mul(power[i-1],5);
key=add(key,mul(get(s1[i-1]),tmp));
tmp=mul(tmp,5);
pre[i]=add(pre[i-1],tmp);
seg.update(1,1,n,i,i,get(s4[i-1]));
}
//cout<<key<<endl;
if (seg.seg[1]==key) cout<<"Yes\n";
else cout<<"No\n";
while (q--)
{
int l,r; char c; cin>>l>>r>>c;
seg.update(1,1,n,l,r,get(c));
if (seg.seg[1]==key) cout<<"Yes\n";
else cout<<"No\n";
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("a.inp","r",stdin);
//freopen("a.out","w",stdout);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
1060 KB |
Output is correct |
2 |
Correct |
65 ms |
1152 KB |
Output is correct |
3 |
Correct |
67 ms |
1096 KB |
Output is correct |
4 |
Correct |
54 ms |
1152 KB |
Output is correct |
5 |
Correct |
58 ms |
1068 KB |
Output is correct |
6 |
Correct |
58 ms |
1088 KB |
Output is correct |
7 |
Correct |
62 ms |
1060 KB |
Output is correct |
8 |
Correct |
61 ms |
1172 KB |
Output is correct |
9 |
Correct |
69 ms |
1112 KB |
Output is correct |
10 |
Correct |
75 ms |
1100 KB |
Output is correct |
11 |
Correct |
65 ms |
1112 KB |
Output is correct |
12 |
Correct |
62 ms |
1076 KB |
Output is correct |
13 |
Correct |
66 ms |
1088 KB |
Output is correct |
14 |
Correct |
60 ms |
1184 KB |
Output is correct |
15 |
Correct |
65 ms |
1100 KB |
Output is correct |
16 |
Correct |
96 ms |
1108 KB |
Output is correct |
17 |
Correct |
62 ms |
1168 KB |
Output is correct |
18 |
Correct |
62 ms |
1112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
1060 KB |
Output is correct |
2 |
Correct |
65 ms |
1152 KB |
Output is correct |
3 |
Correct |
67 ms |
1096 KB |
Output is correct |
4 |
Correct |
54 ms |
1152 KB |
Output is correct |
5 |
Correct |
58 ms |
1068 KB |
Output is correct |
6 |
Correct |
58 ms |
1088 KB |
Output is correct |
7 |
Correct |
62 ms |
1060 KB |
Output is correct |
8 |
Correct |
61 ms |
1172 KB |
Output is correct |
9 |
Correct |
69 ms |
1112 KB |
Output is correct |
10 |
Correct |
75 ms |
1100 KB |
Output is correct |
11 |
Correct |
65 ms |
1112 KB |
Output is correct |
12 |
Correct |
62 ms |
1076 KB |
Output is correct |
13 |
Correct |
66 ms |
1088 KB |
Output is correct |
14 |
Correct |
60 ms |
1184 KB |
Output is correct |
15 |
Correct |
65 ms |
1100 KB |
Output is correct |
16 |
Correct |
96 ms |
1108 KB |
Output is correct |
17 |
Correct |
62 ms |
1168 KB |
Output is correct |
18 |
Correct |
62 ms |
1112 KB |
Output is correct |
19 |
Correct |
356 ms |
16200 KB |
Output is correct |
20 |
Correct |
249 ms |
16172 KB |
Output is correct |
21 |
Correct |
219 ms |
15220 KB |
Output is correct |
22 |
Correct |
179 ms |
13772 KB |
Output is correct |
23 |
Correct |
91 ms |
1952 KB |
Output is correct |
24 |
Correct |
95 ms |
1868 KB |
Output is correct |
25 |
Correct |
195 ms |
16100 KB |
Output is correct |
26 |
Correct |
185 ms |
16152 KB |
Output is correct |
27 |
Correct |
213 ms |
16184 KB |
Output is correct |
28 |
Correct |
211 ms |
16100 KB |
Output is correct |
29 |
Correct |
237 ms |
15856 KB |
Output is correct |
30 |
Correct |
100 ms |
1868 KB |
Output is correct |
31 |
Correct |
203 ms |
16224 KB |
Output is correct |
32 |
Correct |
217 ms |
14760 KB |
Output is correct |
33 |
Correct |
94 ms |
1836 KB |
Output is correct |
34 |
Correct |
228 ms |
16224 KB |
Output is correct |
35 |
Correct |
166 ms |
12336 KB |
Output is correct |
36 |
Correct |
91 ms |
1868 KB |
Output is correct |
37 |
Correct |
92 ms |
1880 KB |
Output is correct |
38 |
Correct |
224 ms |
16188 KB |
Output is correct |
39 |
Correct |
147 ms |
16156 KB |
Output is correct |
40 |
Correct |
148 ms |
11020 KB |
Output is correct |
41 |
Correct |
305 ms |
16360 KB |
Output is correct |
42 |
Correct |
107 ms |
16368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
1060 KB |
Output is correct |
2 |
Correct |
65 ms |
1152 KB |
Output is correct |
3 |
Correct |
67 ms |
1096 KB |
Output is correct |
4 |
Correct |
54 ms |
1152 KB |
Output is correct |
5 |
Correct |
58 ms |
1068 KB |
Output is correct |
6 |
Correct |
58 ms |
1088 KB |
Output is correct |
7 |
Correct |
62 ms |
1060 KB |
Output is correct |
8 |
Correct |
61 ms |
1172 KB |
Output is correct |
9 |
Correct |
69 ms |
1112 KB |
Output is correct |
10 |
Correct |
75 ms |
1100 KB |
Output is correct |
11 |
Correct |
65 ms |
1112 KB |
Output is correct |
12 |
Correct |
62 ms |
1076 KB |
Output is correct |
13 |
Correct |
66 ms |
1088 KB |
Output is correct |
14 |
Correct |
60 ms |
1184 KB |
Output is correct |
15 |
Correct |
65 ms |
1100 KB |
Output is correct |
16 |
Correct |
96 ms |
1108 KB |
Output is correct |
17 |
Correct |
62 ms |
1168 KB |
Output is correct |
18 |
Correct |
62 ms |
1112 KB |
Output is correct |
19 |
Correct |
63 ms |
1096 KB |
Output is correct |
20 |
Correct |
68 ms |
1136 KB |
Output is correct |
21 |
Incorrect |
67 ms |
1100 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
1060 KB |
Output is correct |
2 |
Correct |
65 ms |
1152 KB |
Output is correct |
3 |
Correct |
67 ms |
1096 KB |
Output is correct |
4 |
Correct |
54 ms |
1152 KB |
Output is correct |
5 |
Correct |
58 ms |
1068 KB |
Output is correct |
6 |
Correct |
58 ms |
1088 KB |
Output is correct |
7 |
Correct |
62 ms |
1060 KB |
Output is correct |
8 |
Correct |
61 ms |
1172 KB |
Output is correct |
9 |
Correct |
69 ms |
1112 KB |
Output is correct |
10 |
Correct |
75 ms |
1100 KB |
Output is correct |
11 |
Correct |
65 ms |
1112 KB |
Output is correct |
12 |
Correct |
62 ms |
1076 KB |
Output is correct |
13 |
Correct |
66 ms |
1088 KB |
Output is correct |
14 |
Correct |
60 ms |
1184 KB |
Output is correct |
15 |
Correct |
65 ms |
1100 KB |
Output is correct |
16 |
Correct |
96 ms |
1108 KB |
Output is correct |
17 |
Correct |
62 ms |
1168 KB |
Output is correct |
18 |
Correct |
62 ms |
1112 KB |
Output is correct |
19 |
Correct |
356 ms |
16200 KB |
Output is correct |
20 |
Correct |
249 ms |
16172 KB |
Output is correct |
21 |
Correct |
219 ms |
15220 KB |
Output is correct |
22 |
Correct |
179 ms |
13772 KB |
Output is correct |
23 |
Correct |
91 ms |
1952 KB |
Output is correct |
24 |
Correct |
95 ms |
1868 KB |
Output is correct |
25 |
Correct |
195 ms |
16100 KB |
Output is correct |
26 |
Correct |
185 ms |
16152 KB |
Output is correct |
27 |
Correct |
213 ms |
16184 KB |
Output is correct |
28 |
Correct |
211 ms |
16100 KB |
Output is correct |
29 |
Correct |
237 ms |
15856 KB |
Output is correct |
30 |
Correct |
100 ms |
1868 KB |
Output is correct |
31 |
Correct |
203 ms |
16224 KB |
Output is correct |
32 |
Correct |
217 ms |
14760 KB |
Output is correct |
33 |
Correct |
94 ms |
1836 KB |
Output is correct |
34 |
Correct |
228 ms |
16224 KB |
Output is correct |
35 |
Correct |
166 ms |
12336 KB |
Output is correct |
36 |
Correct |
91 ms |
1868 KB |
Output is correct |
37 |
Correct |
92 ms |
1880 KB |
Output is correct |
38 |
Correct |
224 ms |
16188 KB |
Output is correct |
39 |
Correct |
147 ms |
16156 KB |
Output is correct |
40 |
Correct |
148 ms |
11020 KB |
Output is correct |
41 |
Correct |
305 ms |
16360 KB |
Output is correct |
42 |
Correct |
107 ms |
16368 KB |
Output is correct |
43 |
Correct |
63 ms |
1096 KB |
Output is correct |
44 |
Correct |
68 ms |
1136 KB |
Output is correct |
45 |
Incorrect |
67 ms |
1100 KB |
Output isn't correct |
46 |
Halted |
0 ms |
0 KB |
- |