# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799993 | Tunglam07 | Kemija (COCI22_kemija) | C++17 | 1 ms | 340 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;
int main()
{
long long t, save, cnt[27], id;
bool ck;
string s;
cin >> t;
memset(cnt, 0, sizeof(cnt));
while(t--)
{
save = 1;
ck = 0;
cin >> s;
for(int i = 0; i < s.size(); i++)
{
if(ck == 0 && s[i] >= 48 && s[i] <= 57)
{
save = s[i] - 48;
ck = 1;
}
else if(s[i] >= 48 && s[i] <= 57)
{
cnt[s[i - 1] - 65] += ((s[i] - 49) * save);
}
else if(s[i] > 64 && s[i] < 91)
{
cnt[s[i] - 65] += save;
ck = 1;
}
else if(s[i] == 43)
{
ck = 0;
save = 1;
}
else if(s[i] == 45 && s[i + 1] == 62)
{
id = i + 2;
break;
}
}
ck = 0;
save = 1;
for(int i = id; i < s.size(); i++)
{
if(ck == 0 && s[i] >= 48 && s[i] <= 57)
{
save = s[i] - 48;
ck = 1;
}
else if(s[i] >= 48 && s[i] <= 57)
{
cnt[s[i - 1] - 65] -= (s[i] - 49) * save;
}
else if(s[i] > 64 && s[i] < 91)
{
cnt[s[i] - 65] -= save;
ck = 1;
}
else if(s[i] == 43)
{
ck = 0;
save = 1;
}
}
ck = 0;
for(int i = 0; i < 26; i++)
{
if(cnt[i])
{
ck = 1;
}
cnt[i] = 0;
}
if(ck)
{
cout << "NE" << endl;
}
else
{
cout << "DA" << endl;
}
}
}
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... |