# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1020966 | 2024-07-12T12:14:43 Z | vjudge1 | Kemija (COCI22_kemija) | C++17 | 1 ms | 456 KB |
#include <bits/stdc++.h> #define fast cin.tie(0)->sync_with_stdio(0); #define int long long #define inf ((int)1e18) #define N 200005 using namespace std; typedef array <int, 26> chem; chem bos; void print(chem huh) { cout << "array:\n"; for(int i = 0; i < 2; i++) { cout << huh[i] << " "; } cout << "\n"; }; chem freq(string s) { chem ret = bos; int times = (s[0] < 'A') ? s[0] - '0' : 1; for(int i = (s[0] < 'A') ? 1 : 0; i < s.size(); i++) { if(i + 1 < s.size() and s[i + 1] < 'A') { ret[s[i] - 'A'] += times * (s[i + 1] - '0'); i++; } else { ret[s[i] - 'A'] += times; } } return ret; } chem sum(chem a, chem b) { chem ret; for(int i = 0; i < 26; i++) { ret[i] = a[i] + b[i]; } return ret; } void solve(){ string s; cin >> s; int prev = 0; for(int i = 0; i < 26; i++) { bos[i] = 0; } vector<chem> formula(2, bos); bool side = 0; s.push_back('+'); for(int i = 1; i < s.size(); i++) { if(s[i] == '+' or s[i] == '-') { string t = s.substr(prev, i - prev); chem wtf = freq(t); // print(wtf); formula[side] = sum(formula[side], wtf); prev = i + 1; } if(s[i] == '-') { i++; prev++; side = 1; } } bool yes = 1; for(int i = 0; i < 26; i++) { if(formula[0][i] != formula[1][i]) yes = 0; } if(yes) { cout << "DA\n"; } else { cout << "NE\n"; } } int32_t main(){ fast int t=1; cin >> t; while(t--) solve(); } //
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 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 | 348 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 | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 456 KB | Output is correct |
7 | Correct | 0 ms | 348 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 | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 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 | 348 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 | 1 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 456 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 344 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 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 | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |