# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003420 | 2024-06-20T10:05:14 Z | Lini | Kemija (COCI22_kemija) | C++14 | 1 ms | 440 KB |
#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; 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 440 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 440 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Incorrect | 0 ms | 348 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |