Submission #1003208

# Submission time Handle Problem Language Result Execution time Memory
1003208 2024-06-20T07:49:45 Z Nailuj_217 Kemija (COCI22_kemija) C++17
50 / 50
1 ms 444 KB
#include <bits/stdc++.h>
#define l long long
using namespace std;

array<l, 200> abc;
array<l, 200> firstabc;

int main() {

    l t;
    cin >> t;

    string equation;
    l multiplier, mult2;

    while (t--) {

        cin >> equation;
        equation += "/";
        memset(abc.begin(), 0, 199);
        abc.fill(0);
        firstabc.fill(0);

        for (int i = 0; i < equation.size();) {
            multiplier = 1;
            
            if (isdigit(equation[i])) {
                multiplier = equation[i++] - '0';
            }
            while (equation[i] != '+' && equation[i] != '-' && equation[i] != '/') {
                if (isdigit(equation[i])) i++;
                if (equation[i] == '/' || equation[i] == '+' || equation[i] == '-') break;
                mult2 = 1;
                if (isdigit(equation[i+1])) mult2 = equation[i+1] - '0';
                abc[equation[i++] - 'A'] += multiplier * mult2;
            }


            if (equation[i] == '/') break;
            if (isdigit(equation[i])) i++;

            if (equation[i] == '-') {
                firstabc = abc;
                memset(abc.begin(), 0, 199);
                abc.fill(0);
                i += 2;
            }
            if (equation[i] == '+') i++;
        }

        if (abc == firstabc) cout << "DA" << "\n";
        else cout << "NE" << "\n";
    }
    cout << flush;





    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int i = 0; i < equation.size();) {
      |                         ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 440 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 440 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 444 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 440 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct