結果
| 問題 |
No.1439 Let's Compare!!!!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-26 21:55:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 397 ms / 2,000 ms |
| コード長 | 2,313 bytes |
| コンパイル時間 | 1,131 ms |
| コンパイル使用メモリ | 103,388 KB |
| 実行使用メモリ | 5,504 KB |
| 最終ジャッジ日時 | 2024-11-29 08:45:01 |
| 合計ジャッジ時間 | 5,677 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int e[200020];
set<int> st;
int main() {
int n;
cin >> n;
string s, t;
cin >> s >> t;
for (int i = 0; i < n; i++) {
if (s[i] > t[i]) {
e[i] = 0;
}
else if (s[i] == t[i]) {
e[i] = 1;
}
else {
e[i] = 2;
}
}
if (e[0] != 1) {
st.insert(0);
}
for (int i = 0; i < n - 1; i++) {
if (e[i] == 1 && e[i + 1] != 1) {
st.insert(i + 1);
}
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
char c, y;
int x;
cin >> c >> x >> y;
x--;
if (c == 'S') {
s[x] = y;
if (s[x] > t[x]) {
if (x != n - 1 && e[x] == 1 && e[x + 1] != 1) {
st.erase(x + 1);
}
e[x] = 0;
if (x != 0 && e[x - 1] == 1) {
st.insert(x);
}
if (x == 0) {
st.insert(x);
}
}
else if (s[x] == t[x]) {
if (x != 0 && e[x] != 1 && e[x - 1] == 1) {
st.erase(x);
}
e[x] = 1;
if (x != n - 1 && e[x + 1] != 1) {
st.insert(x + 1);
}
if (x == 0) {
st.erase(x);
}
}
else {
if (x != n - 1 && e[x] == 1 && e[x + 1] != 1) {
st.erase(x + 1);
}
e[x] = 2;
if (x != 0 && e[x - 1] == 1) {
st.insert(x);
}
if (x == 0) {
st.insert(x);
}
}
}
else {
t[x] = y;
if (s[x] > t[x]) {
if (x != n - 1 && e[x] == 1 && e[x + 1] != 1) {
st.erase(x + 1);
}
e[x] = 0;
if (x != 0 && e[x - 1] == 1) {
st.insert(x);
}
if (x == 0) {
st.insert(x);
}
}
else if (s[x] == t[x]) {
if (x != 0 && e[x] != 1 && e[x - 1] == 1) {
st.erase(x);
}
e[x] = 1;
if (x != n - 1 && e[x + 1] != 1) {
st.insert(x + 1);
}
if (x == 0) {
st.erase(x);
}
}
else {
if (x != n - 1 && e[x] == 1 && e[x + 1] != 1) {
st.erase(x + 1);
}
e[x] = 2;
if (x != 0 && e[x - 1] == 1) {
st.insert(x);
}
if (x == 0) {
st.insert(x);
}
}
}
if (st.empty()) {
cout << "=" << endl;
}
else {
if (e[*st.begin()] == 0) {
cout << ">" << endl;
}
else {
cout << "<" << endl;
}
}
}
}