QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695570#7894. Many Many Headsaa1234521#WA 3ms3616kbC++201.1kb2024-10-31 20:18:232024-10-31 20:18:23

Judging History

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

  • [2024-10-31 20:18:23]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3616kb
  • [2024-10-31 20:18:23]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

string st;
vector <char> v;

void solve()
{
  cin >> st;
  bool flag = true;

  for(int i = 0; i < st.size(); i ++ )
  {
    if(st[i] == ']')st[i] = '[';
    if(st[i] == ')')st[i] = '(';
  }

  int it = 0, len = st.size();
  char s1, s2;
  v.clear();
  s1 = st[it];
  while(v.empty() || (it < len && st[it] != v.back()))
  {
    v.push_back(st[it ++ ]);
  }
  while(!v.empty() || (it < len && st[it] == v.back()))
  {
    v.pop_back();
    it ++ ;
  }
  if(!v.empty())flag = false;
  
  if(it < len)
  {
    v.clear();
    s2 = st[it];
    while(v.empty() || (it < len && st[it] != v.back()))
    {
      v.push_back(st[it ++ ]);
    }
    while(!v.empty() || (it < len && st[it] == v.back()))
    {
      v.pop_back();
      it ++ ;
    }
    if(!v.empty())flag = false;
    if(s1 == s2)flag = false;
  }

  if(it < len)flag = false;

  if(flag)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

int main()
{
  int T;
  cin >> T;
  while(T -- )
  {
    solve();
  }

  return 0;
}

詳細信息

Test #1:

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

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

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: 3ms
memory: 3576kb

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

result:

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