QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#196846 | #5615. Two Charts Become One | KKT89 | AC ✓ | 40ms | 8984kb | C++17 | 1.6kb | 2023-10-02 00:37:40 | 2023-10-02 00:37:41 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
inline double time() {
return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
string s,t;
getline(cin, s);
getline(cin, t);
map<pair<int,vector<int>>,int> mp;
auto id = [&](int par, vector<int> &v) -> int {
if (mp.find({par, v}) == mp.end()) {
int sz = mp.size();
mp[{par, v}] = sz;
}
return mp[{par, v}];
};
auto slv = [&](auto slv, string &s, int &idx) -> int {
int cur = 0;
vector<int> v;
while (idx < s.size()) {
if (s[idx] == ' ') {
idx += 1;
}
else if (isdigit(s[idx])) {
cur = cur*10 + s[idx]-'0';
idx += 1;
}
else if (s[idx] == '(') {
idx += 1;
v.push_back(slv(slv, s, idx));
assert(s[idx] == ')');
idx += 1;
}
else {
break;
}
}
sort(v.begin(), v.end());
return id(cur, v);
};
int ii = 0, iii = 0;
if (slv(slv, s, ii) == slv(slv, t, iii)) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
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: 3624kb
input:
11 ( 10 ) ( 12 ) 11(10(12))
output:
No
result:
ok single line: 'No'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
11 (10) (12) 11 (10) (13)
output:
No
result:
ok single line: 'No'
Test #4:
score: 0
Accepted
time: 22ms
memory: 6688kb
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: 4936kb
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: 8ms
memory: 4644kb
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: 8ms
memory: 4832kb
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: 8ms
memory: 4940kb
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: 7ms
memory: 4916kb
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: 6ms
memory: 4644kb
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: 3884kb
input:
10 10
output:
Yes
result:
ok single line: 'Yes'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
10 1
output:
No
result:
ok single line: 'No'
Test #13:
score: 0
Accepted
time: 35ms
memory: 8604kb
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: 35ms
memory: 8608kb
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: 40ms
memory: 8984kb
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: 40ms
memory: 8876kb
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: 1ms
memory: 4236kb
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: 1ms
memory: 3928kb
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: 1ms
memory: 3748kb
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: 3616kb
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: 0ms
memory: 3612kb
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: 0ms
memory: 3672kb
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: 26ms
memory: 6556kb
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'