답안 #427768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427768 2021-06-14T21:58:23 Z DanerZein Crossing (JOI21_crossing) C++14
0 / 100
475 ms 2336 KB
#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";
  }
}

Compilation message

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);
      |     ~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 2052 KB Output is correct
2 Correct 460 ms 2336 KB Output is correct
3 Correct 475 ms 2256 KB Output is correct
4 Incorrect 430 ms 2324 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 2052 KB Output is correct
2 Correct 460 ms 2336 KB Output is correct
3 Correct 475 ms 2256 KB Output is correct
4 Incorrect 430 ms 2324 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 2052 KB Output is correct
2 Correct 460 ms 2336 KB Output is correct
3 Correct 475 ms 2256 KB Output is correct
4 Incorrect 430 ms 2324 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 2052 KB Output is correct
2 Correct 460 ms 2336 KB Output is correct
3 Correct 475 ms 2256 KB Output is correct
4 Incorrect 430 ms 2324 KB Output isn't correct
5 Halted 0 ms 0 KB -