Submission #899422

#TimeUsernameProblemLanguageResultExecution timeMemory
899422HamzaTKemija (COCI22_kemija)C++14
50 / 50
1 ms604 KiB
//struct Edge {int u, v, weight;bool operator<(Edge const& other) {return weight < other.weight;}}; #include <bits/stdc++.h> #define endl "\n" #define ll long long #define sp ' ' #define pb push_back #define ar for(int i=1;i<=n;i++) using namespace std; ll t=1; const ll N=3e5+100; ll n,m,q,k; ll a[N],b[N],c[N]; void solve() { string s;cin>>s; map<char,int>mp;int indx=1; vector<string>v1,v2;string x=""; for(int i=0;i<s.size();i++) { if(s[i]=='+'){v1.push_back(x);x="";continue;} if(s[i]=='-'){i++;indx=i;break;} x+=s[i]; } if(x.size()){v1.push_back(x);}x=""; for(int i=indx+1;i<s.size();i++) { if(s[i]=='+'){v2.push_back(x);x="";continue;} if(s[i]=='-'){i++;indx=i;break;} x+=s[i]; } ll num; if(x.size()){v2.push_back(x);}x=""; for(auto i:v1) { num=0; x=i;indx=0; //2H2O string x2=""; while(x[indx]<'A'||x[indx]>'Z'){x2+=x[indx];indx++;} for(auto j:x2){num*=10;num+=j-'0';} if(num==0){num=1;} for(int j=indx;j<x.size();j++) { if(j+1<x.size()&&x[j+1]>='A'&&x[j+1]<='Z') { mp[x[j]]+=num;continue; } else if(j+1<x.size()&&(x[j+1]<'A'||x[j+1]>'Z')) { ll num2=0; x2=""; int indx2=j+1; while(indx2<x.size()&&(x[indx2]<'A'||x[indx2]>'Z')){x2+=x[indx2];indx2++;} for(auto k:x2){num2*=10;num2+=k-'0';} mp[x[j]]+=num*num2; j=indx2-1; } else{mp[x[j]]+=num;} } } //for(auto i:mp){cout<<i.first<<" "<<i.second<<endl;} for(auto i:v2) { num=0; x=i;indx=0; //2H2O string x2=""; while(x[indx]<'A'||x[indx]>'Z'){x2+=x[indx];indx++;} for(auto j:x2){num*=10;num+=j-'0';} if(num==0){num=1;} for(int j=indx;j<x.size();j++) { if(j+1<x.size()&&x[j+1]>='A'&&x[j+1]<='Z') { mp[x[j]]-=num;continue; } else if(j+1<x.size()&&(x[j+1]<'A'||x[j+1]>'Z')) { ll num2=0; x2=""; int indx2=j+1; while(indx2<x.size()&&(x[indx2]<'A'||x[indx2]>'Z')){x2+=x[indx2];indx2++;} for(auto k:x2){num2*=10;num2+=k-'0';} mp[x[j]]-=num*num2; j=indx2-1; } else{mp[x[j]]-=num;} } } for(auto i:mp){if(i.second!=0){cout<<"NE"<<endl;return;}} cout<<"DA"<<endl;return; } int main() { //freopen("shell.in", "r", stdin); // freopen("shell.out", "w", stdout); ios::sync_with_stdio(NULL); cin.tie(NULL);cout.tie(NULL); cin>>t; while(t--){solve();} return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:18:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
Main.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=indx+1;i<s.size();i++)
      |                      ~^~~~~~~~~
Main.cpp:43:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int j=indx;j<x.size();j++)
      |                        ~^~~~~~~~~
Main.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             if(j+1<x.size()&&x[j+1]>='A'&&x[j+1]<='Z')
      |                ~~~^~~~~~~~~
Main.cpp:49:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             else if(j+1<x.size()&&(x[j+1]<'A'||x[j+1]>'Z'))
      |                     ~~~^~~~~~~~~
Main.cpp:54:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |                 while(indx2<x.size()&&(x[indx2]<'A'||x[indx2]>'Z')){x2+=x[indx2];indx2++;}
      |                       ~~~~~^~~~~~~~~
Main.cpp:72:25: 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 j=indx;j<x.size();j++)
      |                        ~^~~~~~~~~
Main.cpp:74:19: 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(j+1<x.size()&&x[j+1]>='A'&&x[j+1]<='Z')
      |                ~~~^~~~~~~~~
Main.cpp:78:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |             else if(j+1<x.size()&&(x[j+1]<'A'||x[j+1]>'Z'))
      |                     ~~~^~~~~~~~~
Main.cpp:83:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |                 while(indx2<x.size()&&(x[indx2]<'A'||x[indx2]>'Z')){x2+=x[indx2];indx2++;}
      |                       ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...