Submission #667913

# Submission time Handle Problem Language Result Execution time Memory
667913 2022-12-02T11:10:46 Z Manoush Kemija (COCI22_kemija) C++14
50 / 50
1 ms 304 KB
#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
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 292 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct