This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void testCase() {
string s;
cin >> s;
vector<vector<int>> f(2, vector<int>(26));
int index = 0, mul = 1;
for (int i = 0; i < (int)s.size(); ++i) {
if (isdigit(s[i])) {
mul = s[i] - '0';
continue;
}
if (s[i] == '+') {
mul = 1;
continue;
}
if (s[i] == '-' || s[i] == '>') {
index = 1;
mul = 1;
continue;
}
int ch = s[i] - 'A', nxtMul = 1;
if (i + 1 < (int)s.size() && isdigit(s[i + 1])) {
i += 1;
nxtMul = s[i] - '0';
}
f[index][ch] += mul * nxtMul;
}
if (f[0] == f[1]) {
cout << "DA\n";
} else {
cout << "NE\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tests;
cin >> tests;
for (int tc = 0; tc < tests; ++tc) {
testCase();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |