Submission #1003208

#TimeUsernameProblemLanguageResultExecution timeMemory
1003208Nailuj_217Kemija (COCI22_kemija)C++17
50 / 50
1 ms444 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...