結果
| 問題 | No.1439 Let's Compare!!!! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-26 21:47:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 371 ms / 2,000 ms |
| コード長 | 1,634 bytes |
| 記録 | |
| コンパイル時間 | 1,486 ms |
| コンパイル使用メモリ | 169,208 KB |
| 実行使用メモリ | 8,444 KB |
| 最終ジャッジ日時 | 2024-11-29 08:40:51 |
| 合計ジャッジ時間 | 5,889 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
//
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)
typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;
const int N = 2e5 + 5;
const int BASE = 299213;
const int MOD = 929292929;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;
struct BITree {
ll t[N];
int lowbit(int x) {
return x & -x;
}
void add(int x, ll val) {
for (; x < N; x += lowbit(x))
t[x] = (t[x] + val) % MOD;
}
ll query(int x) {
ll ret = 0;
for (; x; x -= lowbit(x))
ret += t[x];
return (ret % MOD + MOD) % MOD;
}
};
BITree bt1, bt2;
string a, b;
ll pbas[N];
int main() {
ios::sync_with_stdio(0);
pbas[0] = 1;
for (int i = 1; i < N; i++)
pbas[i] = 1LL * pbas[i - 1] * BASE % MOD;
int n;
cin >> n;
cin >> a >> b;
a = ' ' + a;
b = ' ' + b;
for (int i = 1; i <= n; i++) {
bt1.add(i, (a[i] - '0') * pbas[i]);
bt2.add(i, (b[i] - '0') * pbas[i]);
}
auto lcp = [&]() {
int L = 1, R = n + 1;
while (L < R) {
int M = (L + R) / 2;
if (bt1.query(M) == bt2.query(M))
L = M + 1;
else
R = M;
}
return L;
};
int q;
cin >> q;
while (q--) {
char op;
int x, y;
cin >> op >> x >> y;
BITree &bt = op == 'S' ? bt1 : bt2;
string &s = op == 'S' ? a : b;
bt.add(x, -(s[x] - '0') * pbas[x]);
s[x] = y + '0';
bt.add(x, (s[x] - '0') * pbas[x]);
int len = lcp();
if (len == n + 1) {
cout << "=" << endl;
} else {
cout << (a[len] < b[len] ? "<" : ">") << endl;
}
}
return 0;
}