結果

問題 No.1439 Let's Compare!!!!
ユーザー 夜
提出日時 2021-03-26 21:55:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 2,313 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 101,720 KB
実行使用メモリ 5,504 KB
最終ジャッジ日時 2024-05-06 22:22:42
合計ジャッジ時間 5,351 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 7 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 345 ms
5,376 KB
testcase_11 AC 363 ms
5,504 KB
testcase_12 AC 388 ms
5,504 KB
testcase_13 AC 364 ms
5,376 KB
testcase_14 AC 360 ms
5,376 KB
testcase_15 AC 340 ms
5,376 KB
testcase_16 AC 342 ms
5,376 KB
testcase_17 AC 335 ms
5,376 KB
testcase_18 AC 300 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
			}
		}
	}
}
0