voidsolve(){ int _; cin >> _; for (int ts = 0; ts < _; ++ts) { int n, m; cin >> n >> m; string str1, str2; str1.reserve(n); str2.reserve(m); cin >> str1 >> str2;
// check str 1 bool f[2] = {false, false}; for (int i = 1; i < n; ++i) if (str1[i] == str1[i - 1]) f[str1[i] - '0'] = true; if (f[0] && f[1]) { cout << "NO" << endl; continue; }
voidsolve(){ int _; cin >> _; for (int ts = 0; ts < _; ++ts) { int n, c; cin >> n >> c; vector<pair<int, int>> data(n); for (auto&item: data) cin >> item.first; for (int i = 0; i < n; ++i) data[i].second = i + 1;
bool flag = true; for (auto&item: data) { if (item.second == 1) continue; if (tot + item.first >= item.second * c) tot += item.first; else flag = false; }
voidsolve(){ int _; cin >> _; for (int ts = 0; ts < _; ++ts) { int n, m, k; cin >> n >> m >> k; vector<vector<int>> start(n + 1), end(n + 1); for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; start[u].push_back(i); end[v].push_back(i); }
set<int> s; map<pair<int, int>, int> ans1; map<int, int> ans2; int ans3 = 0; for (int i = 1; i <= n; ++i) { for (auto&item: start[i]) s.insert(item);
int res = ans3; for (auto&item: ans1) { int tmp = item.second + ans3; auto l = ans2.find(item.first.first), r = ans2.find(item.first.second); if (l != ans2.end()) tmp += l->second; if (r != ans2.end()) tmp += r->second; res = max(res, tmp); }
vector<int> ans2v; ans2v.reserve(ans2.size()); for (auto&item: ans2) ans2v.push_back(item.second); sort(ans2v.begin(), ans2v.end(), greater<>()); if (ans2v.size() == 1) res = max(res, ans2v[0] + ans3); elseif (ans2v.size() > 1) res = max(res, ans2v[0] + ans2v[1] + ans3);