QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#626262 | #7894. Many Many Heads | L_ty | WA | 0ms | 3844kb | C++17 | 1.2kb | 2024-10-10 01:37:08 | 2024-10-10 01:37:08 |
Judging History
answer
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int N = 1e5 + 10;
char s[N];
void solve(){
cin >> s + 1;
int n = strlen(s + 1);
vector<int> v(n + 1);
map<int, int> mp;
for (int i = 1;i<=n;i++){
if(s[i]==')'||s[i]=='(')
v[i] = 1;
else
v[i] = 2;
}
int flag = 0;
for (int i = 2; i <= n;i++){
//cout << v[i] << " " << v[i - 1] << endl;
if(v[i]==v[i-1]){
flag++;
}
else{
int k = flag + 1;
if(k>=3)
k = 3;
mp[k]++;
flag = 0;
}
}
if(flag){
int k = flag + 1;
if(k>=3)
k = 3;
mp[k]++;
flag = 0;
}
cout << mp[1] << " " << mp[2] << " " << mp[3] << endl;
if (!mp[3] && mp[2] <= 2)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
signed main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3844kb
input:
6 )) ((() [()] ()[()]() ([()]) ([])([])
output:
0 1 0 Yes 0 0 1 No 1 1 0 Yes 2 3 0 No 3 1 0 Yes 1 3 0 No
result:
wrong output format YES or NO expected, but 0 found [1st token]