Submission #676961

#TimeUsernameProblemLanguageResultExecution timeMemory
676961MariabfKemija (COCI22_kemija)C++17
50 / 50
1 ms304 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; string s; while(t--){ cin>>s; map<char, int>ma; bool m=false; for(int i=0; i<s.size(); i++){ if(s[i]=='-'||s[i]=='>'){ m=true; continue; } if(s[i]=='+')continue; int coef; if((int)s[i]<65){ coef=(int)s[i]-48; i++; } else coef=1; while(s[i]!='+'&&s[i]!='-'&&i<s.size()){ char c=s[i]; if(m){ if(i<s.size()-1&&(int)s[i+1]<65&&s[i+1]!='-'&&s[i+1]!='+'){ ma[c]-=(s[i+1]-48)*coef; i++; } else{ ma[c]-=coef; } } else{ if(i<s.size()-1&&(int)s[i+1]<65&&s[i+1]!='-'&&s[i+1]!='+'){ ma[c]+=(s[i+1]-48)*coef; i++; } else{ ma[c]+=coef; } } i++; } }bool f=false; for(auto x:ma){ if(x.second!=0){ f=true; break; } }if(f)cout<<"NE\n"; else cout<<"DA\n"; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         for(int i=0; i<s.size(); i++){
      |                      ~^~~~~~~~~
Main.cpp:23:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             while(s[i]!='+'&&s[i]!='-'&&i<s.size()){
      |                                         ~^~~~~~~~~
Main.cpp:26:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                     if(i<s.size()-1&&(int)s[i+1]<65&&s[i+1]!='-'&&s[i+1]!='+'){
      |                        ~^~~~~~~~~~~
Main.cpp:35:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |                     if(i<s.size()-1&&(int)s[i+1]<65&&s[i+1]!='-'&&s[i+1]!='+'){
      |                        ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...