QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626262#7894. Many Many HeadsL_tyWA 0ms3844kbC++171.2kb2024-10-10 01:37:082024-10-10 01:37:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 01:37:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-10-10 01:37:08]
  • 提交

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]