# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003425 | Lini | Kemija (COCI22_kemija) | C++14 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;
vector<vector<pair<char,long>>> eq;
int main() {
long n;
string chem;
cin>>n;
eq.resize(n);
long sec=1;
long molno=1;
long elno=1;
bool found;
for (long i=0; i<n; i++){
sec=1;
molno=1;
elno=1;
found=false;
cin>>chem;
for (long k=0; k<chem.length(); ++k){
char el=chem[k];
if(isdigit(el)){
molno=el-'0';
continue;
}
if (el=='-'){
sec=-1;
continue;
}
if (el=='+' or el=='>'){
molno=1;
if (isdigit(chem[k+1])){
molno = chem[k+1]-'0';
++k;
continue;
}
}
elno=1;
found=false;
if (eq[i].size()!=0){
for (long j=0; j<eq[i].size(); j++){
if (eq[i][j].first == el){
if (isdigit(chem[k+1])){
elno=chem[k+1]-'0';
++k;
}
// cout<<el<<k<<": "<<elno<<"*"<<molno<<"*"<<sec<<endl;
eq[i][j].second += elno*molno*sec;
found=true;
}
}
if (found) {continue;}
}
if (el!='-' and el!='>' and el!='+' and not isdigit(el)){
pair <char, long> p;
p.first=el;
if (isdigit(chem[k+1])){
elno=chem[k+1]-'0';
++k;
}
// cout<<el<<k<<": "<<elno<<"*"<<molno<<"*"<<sec<<endl;
p.second=elno*molno*sec;
eq[i].push_back(p);
}
}
//cout<<eq[i].size()<<endl;
for (long x=0; x<eq[i].size(); ++x){
pair<char, long> elem=eq[i][x];
// cout<<elem.first<<", "<<elem.second<<endl;
}
}
bool balanced;
for (long l=0; l<n; ++l){
balanced=true;
for (pair<char, long> e : eq[l]){
if (e.second!=0){
balanced=false;
break;
}
}
if (balanced){cout<<"DA"<<endl;}
else{cout<<"NE"<<endl;}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |