# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1003425 | Lini | Kemija (COCI22_kemija) | C++14 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |