# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1020933 | vjudge1 | Kemija (COCI22_kemija) | C++17 | 1 ms | 460 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 solve() {
string s;
cin >> s;
vector<int> a('Z' - 'A' + 1);
int curmul = 1;
int negat = 1;
for(int i = 0; i < s.size(); i ++) {
if(s[i] <= '9' && s[i] >= '0') {
if(i == 0 || s[i - 1] == '+' || s[i - 1] == '>') {
curmul = s[i] - '0';
}
else {
a[s[i - 1] - 'A'] += curmul * (s[i] - '1') * negat;
}
}
else if(s[i] == '+') {
curmul = 1;
}
else if(s[i] == '-') {
curmul = 1; negat = -1;
}
else if(s[i] == '>') continue;
else {
a[s[i] - 'A'] += curmul * negat;
}
}
for(auto x:a) {
if(x!=0) {
cout << "NE\n";
return;
}
}
cout << "DA\n";
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while(t--) solve();
}
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... |