Submission #1020933

#TimeUsernameProblemLanguageResultExecution timeMemory
1020933vjudge1Kemija (COCI22_kemija)C++17
50 / 50
1 ms460 KiB
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; vector<int> a('Z' - 'A' + 1); int curmul = 1; int negat = 1; for(int i = 0; i < s.size(); i ++) { if(s[i] <= '9' && s[i] >= '0') { if(i == 0 || s[i - 1] == '+' || s[i - 1] == '>') { curmul = s[i] - '0'; } else { a[s[i - 1] - 'A'] += curmul * (s[i] - '1') * negat; } } else if(s[i] == '+') { curmul = 1; } else if(s[i] == '-') { curmul = 1; negat = -1; } else if(s[i] == '>') continue; else { a[s[i] - 'A'] += curmul * negat; } } for(auto x:a) { if(x!=0) { cout << "NE\n"; return; } } cout << "DA\n"; } int main() { cin.tie(0)->sync_with_stdio(0); int t; cin >> t; while(t--) solve(); }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:10:19: 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...