# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
667913 | Manoush | Kemija (COCI22_kemija) | C++14 | 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>
#define ll long long int
#define F first
#define S second
#define pb push_back
using namespace std;
int main()
{
map<char,ll>nums;
nums['1']=1;
nums['2']=2;
nums['3']=3;
nums['4']=4;
nums['5']=5;
nums['6']=6;
nums['7']=7;
nums['8']=8;
nums['9']=9;
ll t;
cin>>t;
while (t--)
{
string s;
cin>>s;
ll mid=0;
vector<char>r;
vector<char>l;
ll n=s.length();
ll sum=1;
ll c=0;
for (ll i=0;i<n;i++)
{
if (s[i]=='+')
{
sum=1;
}
else if (s[i]=='-')
{
mid++;
sum=1;
}
else if (s[i]=='>')
{
mid++;
sum=1;
}
else {
if (nums[s[i]]>=1)
{
sum=nums[s[i]];
// cout<<"I "<<i<<endl;
}
else
{
c=0;
ll u=sum;
if (i<n-1&&nums[s[i+1]]>=1)
{
u*=nums[s[i+1]];
c=1;
// cout<<"GO"<<endl;
}
if (mid<2)
{
// cout<<"LL"<<endl;
for (ll j=0;j<u;j++)
{
l.pb(s[i]);
// cout<<s[i]<<" ";
}
// cout<<endl;
}
else
{
// cout<<"RR"<<endl;
for (ll j=0;j<u;j++)
{
//cout<<s[i]<<" ";
r.pb(s[i]);
}
// cout<<endl;
}
// cout<<"HELLO"<<endl;
if (c)i++;
}
}
}
sort(r.begin(),r.end());
sort(l.begin(),l.end());
n=r.size();
if (r.size()!=l.size())
{
cout<<"NE"<<endl;
continue;
}
ll con=1;
for (ll i=0;i<n;i++)
{
if (r[i]!=l[i])
{
con=0;
break;
}
}
if (con)cout<<"DA"<<endl;
else cout<<"NE"<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |