QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#749387#7894. Many Many HeadssurenjamtsWA 16ms3832kbC++171.1kb2024-11-15 00:05:072024-11-15 00:05:09

Judging History

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

  • [2024-11-15 00:05:09]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:3832kb
  • [2024-11-15 00:05:07]
  • 提交

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;
    int cnt = 0;
    while( t -- ){
    	cnt ++;
        cin >> s;
        if( cnt == 45 ){
        	cout << s<<"\n";
		}
        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( 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: 0ms
memory: 3832kb

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: 0ms
memory: 3832kb

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: 16ms
memory: 3640kb

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
...

result:

wrong output format YES or NO expected, but ](]](([])[ found [45th token]