結果

問題 No.1439 Let's Compare!!!!
ユーザー Example0911
提出日時 2021-03-26 21:48:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 513 ms / 2,000 ms
コード長 1,137 bytes
コンパイル時間 3,400 ms
コンパイル使用メモリ 203,268 KB
最終ジャッジ日時 2025-01-19 22:16:02
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 1000000007;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	string S, T; cin >> S >> T;
	vector<int>s(N), t(N);
	for (int i = 0; i < N; i++) {
		s[i] = S[i] - '0';
		t[i] = T[i] - '0';
	}
	int Q; cin >> Q;
	vector<int>a(N, 0);
	set<pair<int, int>>st;
	for (int i = 0; i < N; i++) {
		if (s[i] < t[i]) {
			a[i] = -1;
			st.insert({ i, -1 });
		}
		else if(s[i] > t[i]) {
			a[i] = 1;
			st.insert({ i, 1 });
		}
	}
	for (int _ = 0; _ < Q; _++) {
		char c; cin >> c;
		int x, y; cin >> x >> y; x--;
		int tmp = a[x];
		if (c == 'S') {
			s[x] = y;
		}
		else {
			t[x] = y;
		}
		if(tmp != 0)st.erase({ x, tmp });
		if (s[x] < t[x]) {
			a[x] = -1;
			st.insert({ x, -1 });

		}
		else if (s[x] > t[x]) {
			a[x] = 1;
			st.insert({ x, 1 });
		}
		else a[x] = 0;
		if (st.empty())cout << "=" << endl;
		else {
			auto itr = st.begin();
			pair<int, int> p = *itr;
			if (p.second == 1)cout << ">" << endl;
			else cout << "<" << endl;
		}
	}
	return 0;
}
0