QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#94712 | #5615. Two Charts Become One | PetroTarnavskyi# | AC ✓ | 15ms | 4772kb | C++17 | 1.1kb | 2023-04-07 16:00:30 | 2023-04-07 16:01:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
string s;
vector<pair<int, int>> edges[2];
int ptr;
void dfs(int i, int p) {
while (s[ptr] == ' ') {
ptr++;
assert(ptr < SZ(s));
}
int v = 0;
while (ptr < SZ(s) && isdigit(s[ptr])) {
v = 10 * v + s[ptr++] - '0';
}
edges[i].emplace_back(v, p);
while (true) {
while (ptr < SZ(s) && s[ptr] == ' ') {
ptr++;
}
if (ptr == SZ(s)) {
return;
}
if (s[ptr] == '(') {
ptr++;
dfs(i, v);
assert(s[ptr] == ')');
ptr++;
}
else if (s[ptr] == ')') {
return;
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
FOR(i, 0, 2) {
getline(cin, s);
ptr = 0;
dfs(i, -1);
sort(ALL(edges[i]));
}
cout << (edges[0] == edges[1] ? "Yes\n" : "No\n");
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3468kb
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: 3332kb
input:
11 ( 10 ) ( 12 ) 11(10(12))
output:
No
result:
ok single line: 'No'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3312kb
input:
11 (10) (12) 11 (10) (13)
output:
No
result:
ok single line: 'No'
Test #4:
score: 0
Accepted
time: 12ms
memory: 4088kb
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: 2ms
memory: 3556kb
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: 4ms
memory: 3528kb
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: 5ms
memory: 3588kb
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: 5ms
memory: 3576kb
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: 2ms
memory: 3500kb
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: 3524kb
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: 2ms
memory: 3336kb
input:
10 10
output:
Yes
result:
ok single line: 'Yes'
Test #12:
score: 0
Accepted
time: 3ms
memory: 3400kb
input:
10 1
output:
No
result:
ok single line: 'No'
Test #13:
score: 0
Accepted
time: 15ms
memory: 4660kb
input:
289384 (638630 ) (239184 ) (765440 ) (646178 (372606 ) (910028 ) (190096 ) (91605 ) (5527 ) (705508 ) (469479 ) (726199 ) (201953 ) (529344 ) (653748 ) (154974 ) (979397 ) (186316 ) (197719 ) (501602 ) (426553 ) (613347 ) (801743 ) (593510 ) (786392 ) (809643 ) (810562 ) (934493 ) (717125 ) (535195 ...
output:
Yes
result:
ok single line: 'Yes'
Test #14:
score: 0
Accepted
time: 15ms
memory: 4736kb
input:
289384 (638630 ) (239184 ) (765440 ) (646178 (372606 ) (910028 ) (190096 ) (91605 ) (5527 ) (705508 ) (469479 ) (726199 ) (201953 ) (529344 ) (653748 ) (154974 ) (979397 ) (186316 ) (197719 ) (501602 ) (426553 ) (613347 ) (801743 ) (593510 ) (786392 ) (809643 ) (810562 ) (934493 ) (717125 ) (535195 ...
output:
No
result:
ok single line: 'No'
Test #15:
score: 0
Accepted
time: 6ms
memory: 4760kb
input:
289384 (638630 ) (239184 ) (765440 ) (646178 (372606 ) (910028 ) (190096 ) (91605 ) (5527 ) (705508 ) (469479 ) (726199 ) (201953 ) (529344 ) (653748 ) (154974 ) (979397 ) (186316 ) (197719 ) (501602 ) (426553 ) (613347 ) (801743 ) (593510 ) (786392 ) (809643 ) (810562 ) (934493 ) (717125 ) (535195 ...
output:
No
result:
ok single line: 'No'
Test #16:
score: 0
Accepted
time: 9ms
memory: 4772kb
input:
289384 (638630 ) (239184 ) (765440 ) (646178 (372606 ) (910028 ) (190096 ) (91605 ) (5527 ) (705508 ) (469479 ) (726199 ) (201953 ) (529344 ) (653748 ) (154974 ) (979397 ) (186316 ) (197719 ) (501602 ) (426553 ) (613347 ) (801743 ) (593510 ) (786392 ) (809643 ) (810562 ) (934493 ) (717125 ) (535195 ...
output:
No
result:
ok single line: 'No'
Test #17:
score: 0
Accepted
time: 2ms
memory: 3580kb
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 (698714 (656060 (853387 (972741 ...
output:
Yes
result:
ok single line: 'Yes'
Test #18:
score: 0
Accepted
time: 3ms
memory: 3316kb
input:
384 (154 (136 (540 ) (298 ) (133 ) (273 ) (948 ) (61 ) ) (823 (792 ) (348 ) (407 ) (972 ) (916 ) (250 ) (439 ) ) (840 (414 ) (491 ) (450 ) (742 ) (963 ) (606 ) (860 ) (639 ) ) (736 (800 ) ) (591 (595 ) ) (146 (345 ) (249 ) (31 ) (914 ) (976 ) (559 ) ) ) (678 (413 (646 ) (848 ) (720 ) (835 ) (718 ) )...
output:
Yes
result:
ok single line: 'Yes'
Test #19:
score: 0
Accepted
time: 3ms
memory: 3424kb
input:
384 (154 (136 (540 ) (298 ) (133 ) (273 ) (948 ) (61 ) ) (823 (792 ) (348 ) (407 ) (972 ) (916 ) (250 ) (439 ) ) (840 (414 ) (491 ) (450 ) (742 ) (963 ) (606 ) (860 ) (639 ) ) (736 (800 ) ) (591 (595 ) ) (146 (345 ) (249 ) (31 ) (914 ) (976 ) (559 ) ) ) (678 (413 (646 ) (848 ) (720 ) (835 ) (718 ) )...
output:
No
result:
ok single line: 'No'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3396kb
input:
384 (154 (136 (540 (298 (133 (273 (948 (61 (823 (792 ) ) ) ) (348 (407 (972 (916 ) (250 ) ) ) (439 (840 (414 ) (491 ) ) ) ) ) (450 (742 (963 (606 (860 ) ) (639 (736 ) ) ) (800 (591 (595 ) ) (146 (345 ) (249 ) ) ) ) (31 (914 (976 (559 ) (678 ) ) (413 (646 ) ) ) (848 (720 (835 ) ) ) ) ) ) (718 (679 (2...
output:
Yes
result:
ok single line: 'Yes'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3304kb
input:
384 (154 (136 (540 (298 (133 (273 (948 (61 (823 (792 ) ) ) ) (348 (407 (972 (916 ) (250 ) ) ) (439 (840 (414 ) (491 ) ) ) ) ) (450 (742 (963 (606 (860 ) ) (639 (736 ) ) ) (800 (591 (595 ) ) (146 (345 ) (249 ) ) ) ) (31 (914 (976 (559 ) (678 ) ) (413 (646 ) ) ) (848 (720 (835 ) ) ) ) ) ) (718 (679 (2...
output:
No
result:
ok single line: 'No'
Test #22:
score: 0
Accepted
time: 2ms
memory: 3344kb
input:
384 (707 (136 (540 (298 (133 (273 (948 (61 (823 (792 ) ) ) ) (348 (407 (972 (916 ) (250 ) ) ) (439 (840 (414 ) (491 ) ) ) ) ) (450 (742 (963 (606 (860 ) ) (639 (736 ) ) ) (800 (591 (595 ) ) (146 (345 ) (249 ) ) ) ) (31 (914 (976 (559 ) (678 ) ) (413 (646 ) ) ) (848 (720 (835 ) ) ) ) ) ) (718 (679 (2...
output:
No
result:
ok single line: 'No'
Test #23:
score: 0
Accepted
time: 3ms
memory: 4216kb
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:
Yes
result:
ok single line: 'Yes'