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;
int main () {
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int a[26][2] = {};
bool flag = 0; bool flag2 = 0;
int cur = 1; char prev = '0';
for (auto i : s) {
if (i == '-' || i == '>') {
flag = 1; cur = 1; flag2 = 0; prev = '0';
} else if (i == '+') {
flag2 = 0; cur = 1; prev = '0';
} else if (i >= '1' && i <= '9') {
if (flag2) {
a[prev - 'A'][flag] += (i - '0') * cur - cur;
} else {
flag2 = 1;
cur = i - '0';
}
} else {
a[i - 'A'][flag] += cur; prev = i;
flag2 = 1;
}
}
flag = 1;
for (int i = 0; i < 26; i++) flag &= a[i][0] == a[i][1];
cout << (flag ? "DA\n" : "NE\n");
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |