Submission #666263

# Submission time Handle Problem Language Result Execution time Memory
666263 2022-11-28T02:11:39 Z Chal1shkan Kemija (COCI22_kemija) C++14
50 / 50
1 ms 340 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 = 0 + (c > 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 = 0 + (c > 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)
    {
        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:41: 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 = 0 + (c > 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:41: 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 = 0 + (c > 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 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 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 340 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 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 340 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 216 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 320 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