QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749387 | #7894. Many Many Heads | surenjamts | WA | 16ms | 3832kb | C++17 | 1.1kb | 2024-11-15 00:05:07 | 2024-11-15 00:05:09 |
Judging History
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;
int cnt = 0;
while( t -- ){
cnt ++;
cin >> s;
if( cnt == 45 ){
cout << s<<"\n";
}
int cntp = 0, cntd = 0;
vector < char > c;
for(int i = 0; i < s.size(); i ++ ){
if( c.size() == 0 ){
c.pb( s[i] );
continue;
}
if( mp[ c[ c.size()-1 ] ] == mp[ s[i] ] ){
c.pop_back();
if( c.size() == 0 ){
if( mp[ s[i] ] == 1 ){
cntp ++;
}else{
cntd ++;
}
}
}else{
c.pb( s[i] );
}
}
if( cntp >= 2 || cntd >= 2 ){
cout << "No\n";
}else
cout << "Yes\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
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: 3832kb
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: 16ms
memory: 3640kb
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 ...
result:
wrong output format YES or NO expected, but ](]](([])[ found [45th token]