結果

問題 No.1439 Let's Compare!!!!
ユーザー monnumonnu
提出日時 2021-03-26 21:54:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 169,048 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 15:17:55
合計ジャッジ時間 6,494 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 362 ms
4,384 KB
testcase_11 AC 365 ms
4,380 KB
testcase_12 AC 359 ms
4,380 KB
testcase_13 AC 360 ms
4,380 KB
testcase_14 AC 359 ms
4,384 KB
testcase_15 AC 365 ms
4,380 KB
testcase_16 AC 372 ms
4,384 KB
testcase_17 AC 373 ms
4,384 KB
testcase_18 AC 346 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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