Submission #866576

#TimeUsernameProblemLanguageResultExecution timeMemory
866576TAhmed33Kemija (COCI22_kemija)C++98
50 / 50
1 ms600 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...