# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003254 |
2024-06-20T08:15:28 Z |
thelepi |
Kemija (COCI22_kemija) |
C++17 |
|
1 ms |
604 KB |
#include <iostream>
#include <string>
#include <cassert>
using namespace std;
void parseMolecule(int atoms[], string equ, int a, int b){
int multiplier = 1;
bool isnew = true;
char atom = ' ';
for (int j = a; j < b; j++){
char t = equ[j];
if(t - '0' >= 0 && t - '0' < 10){
if(isnew){
multiplier = t - '0';
isnew = false;
}
else{
assert((atom != ' '));
atoms[atom - 'A'] += (t - '0') * multiplier;
atom = ' ';
}
}
else if(t - 'A' >= 0 && t - 'A' < 26){
isnew = false;
if(atom != ' '){
atoms[atom - 'A'] += multiplier;
}
atom = t;
}
}
if(atom != ' '){
atoms[atom - 'A'] += multiplier;
}
}
int main(int, char **)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
string equ;
cin >> equ;
int left[26] = {};
int right[26] = {};
int arrow = equ.find("->");
assert((arrow != equ.npos));
int a = 0;
int b = equ.find_first_of('+');
while(b <= arrow && b != equ.npos){
parseMolecule(left, equ, a, b);
a = b + 1;
b = equ.find_first_of('+', a);
}
parseMolecule(left, equ, a, arrow);
a = arrow + 2;
b = equ.find_first_of('+', a);
while(b != equ.npos){
parseMolecule(right, equ, a, b);
a = b + 1;
b = equ.find_first_of('+', a);
}
parseMolecule(right, equ, a, equ.size());
bool ok = true;
for (int i = 0; i < 26; i++)
{
if(left[i] != right[i]){
ok = false;
}
}
cout << (ok ? "DA\n" : "NE\n");
}
}
Compilation message
In file included from /usr/include/c++/10/cassert:44,
from Main.cpp:3:
Main.cpp: In function 'int main(int, char**)':
Main.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
50 | assert((arrow != equ.npos));
Main.cpp:54:27: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
54 | while(b <= arrow && b != equ.npos){
Main.cpp:62:13: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
62 | while(b != equ.npos){
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
432 KB |
Output is correct |
2 |
Correct |
1 ms |
604 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 |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
432 KB |
Output is correct |
2 |
Correct |
1 ms |
604 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 |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
600 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |