답안 #1003193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003193 2024-06-20T07:39:08 Z Nailuj_217 Kemija (COCI22_kemija) C++17
0 / 50
0 ms 348 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);

        for (int i = 0; i < equation.size();) {
            multiplier = 1;
            
            if (isdigit(equation[i])) {
                multiplier = equation[i++] - '0';
            }
            while (equation[i] != '+' && equation[i] != '-' && equation[i] != '/') {
                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);
                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:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int i = 0; i < equation.size();) {
      |                         ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -