QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#325139 | #5615. Two Charts Become One | weilaifuture# | RE | 2ms | 8396kb | C++14 | 1.3kb | 2024-02-11 04:50:41 | 2024-02-11 04:50:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int tp,x,st[N];
string s1,s2;
vector<int> e1[N],e2[N];
int main(){
getline(cin,s1); getline(cin,s2);
for(char nw: s1){
if(nw<='9'&&nw>='0'){x=x*10+nw-'0'; continue;}
if(x&& tp>=0) e1[st[tp]].push_back(x),st[++tp] = x, x=0;
if(nw==')') tp--;
}
tp=0; st[tp]=0;
for(char nw: s2){
if(nw<='9'&&nw>='0'){x=x*10+nw-'0'; continue;}
if(x && tp>=0) e2[st[tp]].push_back(x),st[++tp] = x, x=0;
if(nw==')') tp--;
}
// for(int i=1;i<=100000;i++){
// if(e1[i].size()==0) continue; sort(e1[i].begin(), e1[i].end());
// cout<<i<<": "; for(int j=0;j<e1[i].size();j++) cout<<e1[i][j]<<" "; cout<<endl;
// }
// for(int i=1;i<=100000;i++){
// if(e2[i].size()==0) continue; sort(e2[i].begin(), e2[i].end());
// cout<<i<<": "; for(int j=0;j<e2[i].size();j++) cout<<e2[i][j]<<" "; cout<<endl;
// }
for(int i=1;i<=100000;i++){
if(e1[i].size()!=e2[i].size()){cout<<"No"; return 0;}
sort(e1[i].begin(), e1[i].end()); sort(e2[i].begin(), e2[i].end());
for(int j=0;j<e1[i].size();j++) if(e1[i][j]!=e2[i][j]){cout<<"No"; return 0;}
}
cout<<"Yes";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 8356kb
input:
11 (10) (12 (13) (17) (28)) 11 (12 (17) (28) (13)) (10)
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 2ms
memory: 8224kb
input:
11 ( 10 ) ( 12 ) 11(10(12))
output:
No
result:
ok single line: 'No'
Test #3:
score: 0
Accepted
time: 0ms
memory: 8396kb
input:
11 (10) (12) 11 (10) (13)
output:
No
result:
ok single line: 'No'
Test #4:
score: -100
Runtime Error
input:
289384 (694459 (751708 (887544 (519034 (207488 (373389 ) (912072 ) (191461 ) (91909 ) (5562 ) (705802 ) (469815 ) (726477 ) ) (204098 (530445 ) (655063 ) (156343 ) (980456 ) (186944 ) (198850 ) ) ) (502461 (427161 (615081 ) (801892 ) (594639 ) (786804 ) (811554 ) (810699 ) (935475 ) (717636 ) ) (537...