# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674987 | jovian_aap | Kemija (COCI22_kemija) | C++17 | 1 ms | 324 KiB |
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 balance(string s) {
vector<int> rctn(100), pdct(100);
bool a = false;
int m = 1;
char l = '0';
for (int i = 0; i < s.size(); i++) {
if (s[i] == '>' || s[i] == '-') {
a = true;
m = 1;
l = '0';
} else if (s[i] == '+') {
m = 1;
l = '0';
} else if (isdigit(s[i])) {
if (l == '0') {
m = s[i] - l;
} else {
if (a) {
pdct[s[i-1] - 'A'] += m*(s[i]-'1');
} else {
rctn[s[i-1] - 'A'] += m*(s[i]-'1');
}
}
} else {
if (a) {
pdct[s[i] - 'A'] += m;
} else {
rctn[s[i] - 'A'] += m;
}
l = s[i];
}
}
if (rctn == pdct) {
cout << "DA" << endl;
} else {
cout << "NE" << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
balance(s);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |