Submission #838535

#TimeUsernameProblemLanguageResultExecution timeMemory
838535Sandarach151Kemija (COCI22_kemija)C++17
50 / 50
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; while(n--){ string s; cin >> s; vector<pair<string, int>> vect1; vector<pair<string, int>> vect2; int pos=0; for(int i=0; i<s.size(); i++){ if(int(s[i])-int('0')<10 && int(s[i])-int('0')>0){ vect1.push_back({"", int(s[i])-int('0')}); i++; } else{ vect1.push_back({"", 1}); } string temp = ""; while(s[i]!='+' && s[i]!='-'){ temp+=s[i]; i++; } vect1.back().first=temp; if(s[i]=='-'){ pos=i+2; break; } } for(int i=pos; i<s.size(); i++){ if(int(s[i])-int('0')<10 && int(s[i])-int('0')>0){ vect2.push_back({"", int(s[i])-int('0')}); i++; } else{ vect2.push_back({"", 1}); } string temp = ""; while(i<s.size() && s[i]!='+' && s[i]!='-'){ temp+=s[i]; i++; } vect2.back().first=temp; if(s[i]=='-'){ pos=i+2; break; } } int ffirst[26]={0}; int ssecond[26]={0}; for(auto u : vect1){ string curs = u.first; int mul = u.second; for(int i=0; i<curs.size(); i++){ int temp = 1; if(i!=curs.size()-1 && int(curs[i+1])-int('0')<10 && int(curs[i+1])-int('0')>0){ temp=int(curs[i+1])-int('0'); } ffirst[int(curs[i])-int('A')]+=temp*mul; if(temp!=1){ i++; } } } for(auto u : vect2){ string curs = u.first; int mul = u.second; for(int i=0; i<curs.size(); i++){ int temp = 1; if(i!=curs.size()-1 && int(curs[i+1])-int('0')<10 && int(curs[i+1])-int('0')>0){ temp=int(curs[i+1])-int('0'); } ssecond[int(curs[i])-int('A')]+=temp*mul; if(temp!=1){ i++; } } } bool res = true; for(int i=0; i<26; i++){ if(ffirst[i]!=ssecond[i]){ res=false; break; } } if(res){ cout << "DA\n"; } else{ cout << "NE\n"; } } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for(int i=0; i<s.size(); i++){
      |                      ~^~~~~~~~~
Main.cpp:34:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i=pos; i<s.size(); i++){
      |                        ~^~~~~~~~~
Main.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             while(i<s.size() && s[i]!='+' && s[i]!='-'){
      |                   ~^~~~~~~~~
Main.cpp:58:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for(int i=0; i<curs.size(); i++){
      |                          ~^~~~~~~~~~~~
Main.cpp:60:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |                 if(i!=curs.size()-1 && int(curs[i+1])-int('0')<10 && int(curs[i+1])-int('0')>0){
      |                    ~^~~~~~~~~~~~~~~
Main.cpp:72:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |             for(int i=0; i<curs.size(); i++){
      |                          ~^~~~~~~~~~~~
Main.cpp:74:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |                 if(i!=curs.size()-1 && int(curs[i+1])-int('0')<10 && int(curs[i+1])-int('0')>0){
      |                    ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...