Submission #674987

#TimeUsernameProblemLanguageResultExecution timeMemory
674987jovian_aapKemija (COCI22_kemija)C++17
50 / 50
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; void balance(string s) { vector<int> rctn(100), pdct(100); bool a = false; int m = 1; char l = '0'; for (int i = 0; i < s.size(); i++) { if (s[i] == '>' || s[i] == '-') { a = true; m = 1; l = '0'; } else if (s[i] == '+') { m = 1; l = '0'; } else if (isdigit(s[i])) { if (l == '0') { m = s[i] - l; } else { if (a) { pdct[s[i-1] - 'A'] += m*(s[i]-'1'); } else { rctn[s[i-1] - 'A'] += m*(s[i]-'1'); } } } else { if (a) { pdct[s[i] - 'A'] += m; } else { rctn[s[i] - 'A'] += m; } l = s[i]; } } if (rctn == pdct) { cout << "DA" << endl; } else { cout << "NE" << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { string s; cin >> s; balance(s); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void balance(std::string)':
Main.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < s.size(); i++) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...