QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748768#7894. Many Many Headssurenjamts#WA 27ms3848kbC++172.1kb2024-11-14 21:23:112024-11-14 21:23:11

Judging History

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

  • [2024-11-14 21:23:11]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3848kb
  • [2024-11-14 21:23:11]
  • 提交

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 opp = 0;
        vector < char > c;
        for(int i = 0; i < s.size(); i ++ ){
            if( c.size() == 0 ){
                c.pb( s[i] );
                if( mp[ s[i] ] == -1 ){
                    opp ++;
                }
                continue;
            }
            if( opp > 0 ){
                if( mp[ s[i] ] == mp[ c[ c.size()-1 ] ] ){
                    c.pop_back();
                    if( mp[ s[i] ] == -1 )
                        opp --;
                }else{
                    c.pb( s[i] );
                    if( mp[ s[i] ] == -1 )
                        opp ++;
                }
                continue;
            }else{
                c.pb( s[i] );
                if( mp[ s[i] ] == -1 ){
                    opp ++;
                }
            }
        }
        string ans = "Yes";
        if( c.size()>=4 ){

            ans = "No";
        }
        c.clear();
        for(int i = 0; i < s.size(); i ++ ){
            if( c.size() == 0 ){
                c.pb( s[i] );
                if( mp[ s[i] ] == 1 ){
                    opp ++;
                }
                continue;
            }
            if( opp > 0 ){
                if( mp[ s[i] ] == mp[ c[ c.size()-1 ] ] ){
                    c.pop_back();
                    if( mp[ s[i] ] == 1 )
                        opp --;
                }else{
                    if( mp[ s[i] ] == 1 )
                        opp ++;
                    c.pb( s[i] );
                }
                continue;
            }else{
                c.pb( s[i] );
                if( mp[ s[i] ] == 1 ){
                    opp ++;
                }
            }
        }
        if( c.size()>=4 ){
            ans = "No";
        }
        cout << ans << "\n";
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3848kb

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: 3528kb

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: 27ms
memory: 3636kb

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]