이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define index int mid=(a+b)/2,le=(2*node+1),ri=(2*node+2);
using namespace std;
typedef long long ll;
const int MAX_P=2e5*4;
string y;
int tr[MAX_P],la[MAX_P];
void init(int node,int a,int b){
if(a==b){
if(y[a]=='J') tr[node]=0;
if(y[a]=='O') tr[node]=1;
if(y[a]=='I') tr[node]=2;
la[node]=-1;
return;
}
index;
init(le,a,mid);
init(ri,mid+1,b);
tr[node]=tr[le]+tr[ri];
la[node]=-1;
}
void propagar(int node,int a,int b){
if(la[node]==-1) return;
int aux=la[node];
tr[node]=aux*((a-b)+1);
la[node]=-1;
if(a==b) return;
index;
la[le]=aux;
la[ri]=aux;
}
void update(int node,int a,int b,int l,int r,int val){
propagar(node,a,b);
if(l>b || r<a) return;
if(l<=a && r>=b){
la[node]=val;
propagar(node,a,b);
return;
}
index;
update(le,a,mid,l,r,val);
update(ri,mid+1,b,l,r,val);
tr[node]=tr[le]+tr[ri];
}
int main(){
int n,q;
string a,b,c;
cin>>n>>a>>b>>c>>q>>y;
int s=0;
init(0,0,n-1);
for(int i=0;i<n;i++){
if(a[i]=='O') s+=1;
if(a[i]=='I') s+=2;
}
if(a==y) cout<<"Yes\n";
else cout<<"No\n";
for(int i=0;i<q;i++){
int l,r;
char x;
cin>>l>>r>>x;
l--; r--;
int aux;
if(x=='J') aux=0;
if(x=='O') aux=1;
if(x=='I') aux=2;
update(0,0,n-1,l,r,aux);
if(tr[0]==s) cout<<"Yes\n";
else cout<<"No\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void propagar(int, int, int)':
Main.cpp:2:19: warning: unused variable 'mid' [-Wunused-variable]
2 | #define index int mid=(a+b)/2,le=(2*node+1),ri=(2*node+2);
| ^~~
Main.cpp:28:3: note: in expansion of macro 'index'
28 | index;
| ^~~~~
Main.cpp: In function 'int main()':
Main.cpp:66:11: warning: 'aux' may be used uninitialized in this function [-Wmaybe-uninitialized]
66 | update(0,0,n-1,l,r,aux);
| ~~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |