QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425758 | #7894. Many Many Heads | Repeater# | WA | 7ms | 3808kb | C++20 | 1.3kb | 2024-05-30 16:43:24 | 2024-05-30 16:43:25 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
void repeater()
{
std::string s; std::cin >> s;
int n = s.size();
std::map<std::string, int> cnt;
std::vector<int> stk;
std::string cur = "";
for(auto i : s)
{
if(i == '(' || i == ')')
{
if(stk.empty())
{
stk.emplace_back(1);
cur += "(";
}
else
{
if(stk.back() == 1)
{
stk.pop_back();
cur += ")";
if(stk.empty())
{
std::string tmp = "";
tmp += cur[0];
tmp += cur.back();
cnt[tmp]++, cur = "";
}
}
else
{
stk.emplace_back(1);
cur +="(";
}
}
}
else
{
if(stk.empty())
{
stk.emplace_back(0);
cur += "[";
}
else
{
if(stk.back() == 0)
{
stk.pop_back();
cur += "]";
if(stk.empty())
{
std::string tmp = "";
tmp += cur[0];
tmp += cur.back();
cnt[tmp]++, cur = "";
}
}
else
{
stk.emplace_back(0);
cur +="[";
}
}
}
}
for(auto [x, y] : cnt) if(y >= 2)
{
std::cout << "No\n";
return;
}
std::cout << "Yes\n";
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t; std::cin >> t;
while(t--) repeater();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3808kb
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: 1ms
memory: 3580kb
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: 7ms
memory: 3596kb
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]