# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799478 | tlnk07 | Kemija (COCI22_kemija) | C++17 | 1 ms | 304 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;
long long n, nho, cnt[101], chk, pos;
string s;
int main()
{
cin >> n;
memset(cnt, 0, sizeof(cnt));
while(n--)
{
nho = 1;
chk = 0;
cin >> s;
for(int i = 0; i < s.size(); ++i)
{
if(chk == 0 && s[i] >= '0' && s[i] <= '9')
{
nho = s[i] - '0';
chk = true;
}
else if(s[i] >= '0' && s[i] <= '9') cnt[s[i - 1] - 'A'] += ((s[i] - '1') * nho);
else if(s[i] >= 'A' && s[i] <= 'Z')
{
cnt[s[i] - 'A'] += nho;
chk = 1;
}
else if(s[i] == '+') chk = 0;
else if(s[i] == '-' && s[i + 1] == '>')
{
pos = i + 2;
break;
}
}
chk = 0;
nho = 1;
for(int i = pos; i < s.size(); ++i)
{
if(chk == 0 && s[i] >= '0' && s[i] <= '9')
{
nho = s[i] - '0';
chk = true;
}
else if(s[i] >= '0' && s[i] <= '9') cnt[s[i - 1] - 'A'] -= (s[i] - '1') * nho;
else if(s[i] >= 'A' && s[i] <= 'Z')
{
cnt[s[i] - 'A'] -= nho;
chk = 1;
}
else if(s[i] == '+') chk = 0;
}
chk = 0;
for(int i = 0; i < 26; ++i)
{
if(cnt[i])
{
chk = true;
}
cnt[i] = 0;
}
if(chk) cout << "NE\n";
else cout << "DA\n";
}
}
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... |