QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748985#7894. Many Many HeadssurenjamtsWA 19ms3768kbC++201.1kb2024-11-14 22:15:332024-11-14 22:15:33

Judging History

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

  • [2024-11-14 22:15:33]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:3768kb
  • [2024-11-14 22:15:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
signed main(){
    int t;
    string s;
    cin >> t;
    map < char, int > mp;
    mp[ '(' ] = mp[')'] = 1;
    mp[ '[' ] = mp[']'] = -1;
    while( t -- ){
        cin >> s;
        int cntp = 0, cntd = 0;
        vector < char > c;
        for(int i = 0; i < s.size(); i ++ ){
            if( c.size() == 0 ){
                c.pb( s[i] );
                continue;
            }
            if( mp[ c[ c.size()-1 ] ] == mp[ s[i] ] ){
                c.pop_back();
                if( c.size() == 0 ){
                    if( mp[ s[i] ] == 1 ){
                        cntp ++;
                    }else{
                        cntd ++;
                    }
                }
            }else{
                c.pb( s[i] );
            }
        }
        if( c.size() != 0 ){
            cout << "No\n";
            continue;
        }
        if( cntp >= 2 || cntd >= 2 ){
            cout << "No\n";
        }else
            cout << "Yes\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

Yes
No
Yes
No
Yes
No

result:

ok 6 token(s): yes count is 3, no count is 3

Test #2:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

2
(([([[([
]]))])]])]

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: -100
Wrong Answer
time: 19ms
memory: 3740kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
Yes
No
Yes
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No...

result:

wrong answer expected NO, found YES [45th token]