Submission #666262

# Submission time Handle Problem Language Result Execution time Memory
666262 2022-11-28T02:09:38 Z Chal1shkan Kemija (COCI22_kemija) C++17
0 / 50
1 ms 328 KB
# include <bits/stdc++.h>

# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define pii pair <int, int>
# define pll pair <ll, ll>
  
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
  
const ll maxn = 2e6 + 125;
const ll maxl = 20 + 0;
const ll inf = 2e9 + 0;
const ll mod = 998244353;

using namespace std;

void ma1n ()
{
    set <char> st;
    map <char, int> mp1, mp2;
    string s;
    cin >> s;
    int pos = s.find('-');
    string x = "";
    for (int i = 0; i <= pos; ++i)
    {
        if (s[i] == '+' || i == pos)
        {
            int c = 1;
            if (x[0] >= '2' && x[0] <= '9')
            {
                c = (x[0] - '0');
            }
            for (int i = 1; i < x.size(); ++i)
            {
                if (x[i] >= 'A' && x[i] <= 'Z')
                {
                    st.insert(x[i]);
                    int val = 1;
                    if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9'))
                    {
                        val = (x[i + 1] - '0');
                    }
                    mp1[x[i]] += (val * c);
                }             
            }
            x.clear();
        }
        else
        {
            x += s[i];
        }
    }
    pos += 2;
    for (int i = pos; i <= s.size(); ++i)
    {
        if (s[i] == '+' || i == s.size())
        {
            int c = 1;
            if (x[0] >= '2' && x[0] <= '9')
            {
                c = (x[0] - '0');
            }
            for (int i = 1; i < x.size(); ++i)
            {
                if (x[i] >= 'A' && x[i] <= 'Z')
                {
                    st.insert(x[i]);
                    int val = 1;
                    if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9'))
                    {
                        val = (x[i + 1] - '0');
                    }
                    mp2[x[i]] += (val * c);
                }             
            }
            x.clear();
        }
        else
        {
            x += s[i];
        }
    }
    for (char c : st)
    {
    //  cout << "vot " << c << nl;
        if (mp1[c] != mp2[c])
        {
            cout << "NE" << nl;
            return;
        }
    }
    cout << "DA" << nl;
}       
    
int main ()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int ttt = 1;
    cin >> ttt;
    for (int test = 1; test <= ttt; test++)
    {
//      cout << "Case " << test << ":" << nl;
        ma1n();
    }
    return 0;
}

Compilation message

Main.cpp: In function 'void ma1n()':
Main.cpp:38:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             for (int i = 1; i < x.size(); ++i)
      |                             ~~^~~~~~~~~~
Main.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |                     if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9'))
      |                         ~~~~~~^~~~~~~~~~
Main.cpp:59:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = pos; i <= s.size(); ++i)
      |                       ~~^~~~~~~~~~~
Main.cpp:61:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         if (s[i] == '+' || i == s.size())
      |                            ~~^~~~~~~~~~~
Main.cpp:68:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             for (int i = 1; i < x.size(); ++i)
      |                             ~~^~~~~~~~~~
Main.cpp:74:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |                     if (i + 1 < x.size() && (x[i + 1] >= '2' && x[i + 1] <= '9'))
      |                         ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -