QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717769#7894. Many Many HeadsshuanglinWA 6ms3868kbC++141.8kb2024-11-06 18:55:102024-11-06 18:55:10

Judging History

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

  • [2024-11-06 18:55:10]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3868kb
  • [2024-11-06 18:55:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lowbit(x)  ((x) & - (x))
using PII = pair<int, int>;
using PIII = tuple<int, int, int>;
const int MOD = 1e9 + 7;
inline int mypow(int n, int k, int p = MOD) {
	int r = 1;
	for (; k; k >>= 1, n = n * n % p) {
		if (k & 1) r = r * n % p;
	}
	return r;
}
struct cmp {  //priority_queue
	bool operator()(const PIII& a, const PIII& b) {
		return std::get<0>(a) < std::get<0>(b); //down
	}
};

bool cmpsort(const PII& a, const PII& b) {  //sort
	return a.first < b.first; //up
}

string str;
deque <pair<int,char> > e;
map<int,int> mp1;
map<int,int> mp2;
inline void solve() {
    cin>>str;
    str=" "+str;
    for(int i=1;i<str.size();i++){
        if(e.empty()){
            e.push_back(make_pair(i,str[i]));
            continue;
        }
        if(str[i]=='('||str[i]==')'){
            if(e.back().second=='['){
                e.push_back(make_pair(i,'('));
            }
            else{
                e.pop_back();
                mp1[e.size()]++;
            }
        }
        else{
            if(e.back().second=='('){
                e.push_back(make_pair(i,'['));
            }
            else{
                e.pop_back();
                mp2[e.size()]++;
            }
        }
    }
    for(auto it:mp1){
        if(it.second>=2){
            cout<<"No"<<'\n';
            return ;
        }
    }
    for(auto it:mp2){
        if(it.second>=2){
            cout<<"No"<<'\n';
            return ;
        }
    }
    cout<<"Yes"<<'\n';
}
signed main() {
	ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
	//cout << fixed << setprecision(12);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
        mp1.clear();
        mp2.clear();
	}
}

詳細信息

Test #1:

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

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

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: 6ms
memory: 3624kb

input:

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

output:

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

result:

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