《补题》(牛客小白月赛66:再交换)

60 阅读1分钟

思维——构造

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
	int n;
	std::cin >> n;

	std::string a, b;
	std::cin >> a >> b;

	for (int i = 0; i < n; i ++) {
		if (a[i] > b[i]) {
			std::cout << i + 1 << " " << i + 1 << "\n";
			return;
		} else if (a[i] < b[i] && i != n - 1) {
			std::cout << i + 2 << " " << i + 2 << "\n";
			return;
		}
	}

	std::cout << 1 << " " << 1 << "\n";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int t;
	std::cin >> t;

	while (t --) {
		solve();
	}

	return 0;
}