QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#325303 | #5615. Two Charts Become One | ape_pack | WA | 17ms | 14824kb | C++23 | 1.8kb | 2024-02-11 07:35:49 | 2024-02-11 07:35:50 |
Judging History
answer
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include<set>
#include<cstring>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
int main(){
vector<vector<int>> parents(2);
for(int i = 0; i < 2; i++){
vector<int> nv(1000001, -2); parents[i] = nv; // ADD CHECK FOR DEPARTMENTAL HEIRARCHY BEING THE ONLY ONE SEEN
}
char c;
//int curr_list = 0;
for (int curr_list = 0; curr_list < 2; curr_list++) {
stack<string> prev_stack;
string curr_num = "";
string s;
getline(cin, s);
//cout << s << endl;
for (int j = 0; j < s.size(); j++) {
c = s[j];
// if(c == '\n'){
// if(parents[curr_list][stoi(curr_num)] == -2){
// parents[curr_list][stoi(curr_num)] = -1;
// }
// curr_list++;
// } else
if (c == '(') {
prev_stack.push(curr_num);
curr_num = "";
} else if (c == ')') {
if (prev_stack.empty()) cout << "EMPTY!" << endl;
string parent = prev_stack.top();
prev_stack.pop();
parents[curr_list][stoi(curr_num)] = stoi(parent);
curr_num = parent;
} else if (c != ' ') {
curr_num += c;
}
}
}
//cout << "Got here..." << endl;
for(int i = 0; i < 1000001; i++){
if(parents[0][i] != parents[1][i]){
cout << "No" << endl;
//cout << "No, " << i << " has parent " << parents[0][i] << " vs " << parents[1][i] << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 14760kb
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: 0ms
memory: 14648kb
input:
11 ( 10 ) ( 12 ) 11(10(12))
output:
No
result:
ok single line: 'No'
Test #3:
score: 0
Accepted
time: 0ms
memory: 14824kb
input:
11 (10) (12) 11 (10) (13)
output:
No
result:
ok single line: 'No'
Test #4:
score: 0
Accepted
time: 17ms
memory: 14576kb
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...
output:
No
result:
ok single line: 'No'
Test #5:
score: 0
Accepted
time: 7ms
memory: 14508kb
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 ) (537132 ) ) ...
output:
Yes
result:
ok single line: 'Yes'
Test #6:
score: 0
Accepted
time: 3ms
memory: 14736kb
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 ) (537132 ) ) ...
output:
No
result:
ok single line: 'No'
Test #7:
score: 0
Accepted
time: 13ms
memory: 14560kb
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 (537132 ) (678...
output:
Yes
result:
ok single line: 'Yes'
Test #8:
score: 0
Accepted
time: 3ms
memory: 14688kb
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 (537132 ) (678...
output:
No
result:
ok single line: 'No'
Test #9:
score: 0
Accepted
time: 5ms
memory: 14712kb
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 (537132 (678641 ) (777412 ) ) (6...
output:
Yes
result:
ok single line: 'Yes'
Test #10:
score: 0
Accepted
time: 4ms
memory: 14736kb
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 (537132 (678641 ) (777412 ) ) (6...
output:
No
result:
ok single line: 'No'
Test #11:
score: 0
Accepted
time: 0ms
memory: 14740kb
input:
10 10
output:
Yes
result:
ok single line: 'Yes'
Test #12:
score: -100
Wrong Answer
time: 3ms
memory: 14732kb
input:
10 1
output:
Yes
result:
wrong answer 1st lines differ - expected: 'No', found: 'Yes'