제출 #676960

#제출 시각아이디문제언어결과실행 시간메모리
676960MariabfKemija (COCI22_kemija)C++17
0 / 50
1 ms212 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){ cout<<'!'<<x.first<<' '<<x.second; f=true; break; } }if(f)cout<<"NE\n"; else cout<<"DA\n"; } }

컴파일 시 표준 에러 (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...