I have found a very short solution of [problem:1997C] compared to what's available everywhere.↵
Please upvote if found helpful.↵
↵
[user:Shayan,2024-08-03] Is there any edge case for this solution?↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
#define nl '\n'↵
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);↵
↵
void solve() {↵
int n; cin >> n;↵
string s; cin >> s;↵
int ans = 0;↵
for (int i = 0; i < n; i += 2) {↵
if (s[i + 1] == ')') {↵
ans += 1;↵
}↵
else {↵
ans += 3;↵
}↵
}↵
cout << ans << nl;↵
}↵
↵
int main() {↵
FAST_IO↵
int tc; cin >> tc;↵
while (tc--) {solve();}↵
}↵
~~~~~↵
↵
Please upvote if found helpful.↵
↵
[user:Shayan,2024-08-03] Is there any edge case for this solution?↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
#define nl '\n'↵
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);↵
↵
void solve() {↵
int n; cin >> n;↵
string s; cin >> s;↵
int ans = 0;↵
for (int i = 0; i < n; i += 2) {↵
if (s[i + 1] == ')') {↵
ans += 1;↵
}↵
else {↵
ans += 3;↵
}↵
}↵
cout << ans << nl;↵
}↵
↵
int main() {↵
FAST_IO↵
int tc; cin >> tc;↵
while (tc--) {solve();}↵
}↵
~~~~~↵
↵