QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748142#7894. Many Many Headssurenjamts#WA 19ms3768kbC++172.7kb2024-11-14 19:28:392024-11-14 19:28:40

Judging History

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

  • [2024-11-14 19:28:40]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:3768kb
  • [2024-11-14 19:28:39]
  • 提交

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;
    while( t -- ){
        cin >> s;
        vector < pair< char, int > > c;
        vector < pair< int, int > > a, b;
        c.clear();
        for(int i = 0; i < s.size(); i ++ ){
            if( c.size() == 0 ){
                c.pb( {s[i], i} );
                continue;
            }
            if( c[ c.size()-1 ].F == '(' || c[ c.size()-1 ].F == ')' ){
                if( s[i] == '(' || s[i] == ')' ){
                    a.pb( { c[ c.size()-1 ].S, i } );
                    c.pop_back();
                    continue;
                }
            }else{
                if( s[i] == '[' || s[i] == ']' ){
                    a.pb( { c[ c.size()-1 ].S, i } );
                    c.pop_back();
                    continue;
                }
            }
            c.pb( {s[i],i} );
        }
        int l = 0, r = s.size()-1;
        c.clear();
        //cout << "gege\n";
//          0123456
//        ([])([])

        while( l < r ){
            //cout << l << " " << r << "\n";
            if( l == 5 && r == 6 )
                break;
            if( (s[l] == '(' || s[l] == ')' ) && ( s[r] == '(' || s[r] == ')' ) ){
                b.pb( {l, r} );
                l ++, r --;
                continue;
            }
            if( (s[l] == '[' || s[l] == ']' ) && ( s[r] == '[' || s[r] == ']' ) ){
                b.pb( {l, r} );
                l ++, r --;
                continue;
            }
            bool flag = false;
            for(int i = l ; i <= r; i ++ ){
                if( c.size() == 0 ){
                    if( flag ){
                        l = i;
                        break;
                    }
                    flag = true;
                    c.pb( {s[i], i} );
                    continue;
                }
                if( c[ c.size()-1 ].F == '(' || c[ c.size()-1 ].F == ')' ){
                    if( s[i] == '(' || s[i] == ')' ){
                        b.pb( { c[ c.size()-1 ].S, i } );
                        c.pop_back();
                        continue;
                    }
                }else{
                    if( s[i] == '[' || s[i] == ']' ){
                        b.pb( { c[ c.size()-1 ].S, i } );
                        c.pop_back();
                        continue;
                    }
                }
                c.pb( {s[i],i} );
            }
        }
        sort( a.begin(), a.end() );
        sort( b.begin(), b.end() );
        if( a != b ){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    }
}

詳細信息

Test #1:

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

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

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

input:

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

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
No
No
No
No
No
Yes
Yes
No
No
Yes
No
No
No
Yes
Yes
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
N...

result:

wrong answer expected YES, found NO [22nd token]