結果

問題 No.1439 Let's Compare!!!!
ユーザー monnu
提出日時 2021-03-26 21:54:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 170,004 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 08:44:20
合計ジャッジ時間 5,806 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 50
#define MOD 1000000007
#define INF 1000000000

int n=1;
vector<char> tree;
void update(int x,char y){
  x+=n-1;
  tree[x]=y;
  while(x>0){
    x=(x-1)/2;
    char a=tree[2*x+1];
    char b=tree[2*x+2];
    if(a!='='){
      tree[x]=a;
    }else{
      tree[x]=b;
    }
  }
}

int main(){
  int N;
  string S,T;
  cin>>N>>S>>T;
  while(n<N){
    n<<=1;
  }
  tree.resize(2*n-1,'=');
  for(int i=0;i<N;i++){
    if(S[i]<T[i]){
      update(i,'<');
    }else if(S[i]>T[i]){
      update(i,'>');
    }else{
      update(i,'=');
    }
  }

  int Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    char c;
    int x;
    char y;
    cin>>c>>x>>y;
    x--;
    if(c=='S'){
      S[x]=y;
    }else{
      T[x]=y;
    }
    if(S[x]<T[x]){
      update(x,'<');
    }else if(S[x]>T[x]){
      update(x,'>');
    }else{
      update(x,'=');
    }
    cout<<tree[0]<<'\n';
  }
}
0