A#include <bits/stdc++.h>using namespace std;int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<string> s(n + 1); vector<int> sz(n + 1, 0); for (int i = 1; i <= n; i++) cin >> s[i], sz[i] = s[i].size(); int ans = 1, cnt = 1; for (int i = 2; i <= n; i++) { if (sz[i] > sz[i - 1]) { cnt++; } else if (sz[i] == sz[i - 1]) { if (s[i] >= s[i - 1]) cnt++; else { ans = max(ans, cnt); cnt = 1; } } else { ans = max(ans, cnt); cnt = 1; } } ans = max(ans, cnt); cout << ans << "\n"; }}// 64 位输出请用 printf("%lld")B#include <bits/stdc++.h>using namespace std;int main() { int n; cin >> n; string s; cin >> s; int ans = 0, bj = 0; int now = 0, l = 0, r = 0; vector<pair<char, int>> v; vector<array<int, 2>> va; for (auto c : s) { now++; if (!v.empty()) { if (c == '(') { if (bj) { while (!va.empty() && l < va.back()[0]) va.pop_back(); va.push_back({l, r}); bj = 0; } v.emplace_back(c, now); } else { if (v.back().first == '(') { bj = 1; l = v.back().second; r = now; v.pop_back(); } else { if (bj) { while (!va.empty() && l < va.back()[0]) va.pop_back(); va.push_back({l, r}); bj = 0; } v.emplace_back(c, now); } } } else { if (bj) { while (!va.empty() && l < va.back()[0]) va.pop_back(); va.push_back({l, r}); bj = 0; } v.emplace_back(c, now); } } if (bj) { while (!va.empty() && l < va.back()[0]) va.pop_back(); va.push_back({l, r}); bj = 0; } ans = v.size(); for (int i = 1; i < va.size(); i++) { if (va[i][0] != (va[i - 1][1] + 1)) { ans++; } } if(va.size()) ans++; cout << ans;}// 64 位输出请用 printf("%lld")C#include <bits/stdc++.h>using namespace std;const int N = 100010;int a[N], b[N];int main() { int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) cin >> a[i]; vector<vector<array<int, 2>>> v1, v2; for (int i = 1; i <= n; i++) { int k; cin >> k; vector<array<int, 2>> t; for (int i = 1; i <= k; i++) { int x, y; cin >> x >> y; t.push_back({x, y}); } v1.push_back(t); cin >> k; t.clear(); for (int i = 1; i <= k; i++) { int x, y; cin >> x >> y; t.push_back({x, y}); } v2.push_back(t); } while (true) { bool tj = 1; for (int i = 0; i < n; i++) if(!b[i]) { bool ok = 1; for (auto [x, y] : v2[i]) { if (a[x] < y) ok = 0; } if (ok) { b[i] = 1; for (auto [x, y] : v1[i]) { a[x] += y; } tj = 0; } } if (tj) break; } vector<int> ans; for (int i = 0; i < n; i++) if(!b[i]) ans.push_back(i + 1); cout << ans.size() << "\n"; for (auto c : ans) { cout << c << " "; }}// 64 位输出请用 printf("%lld")D 不会