# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838535 | 2023-08-27T10:59:58 Z | Sandarach151 | Kemija (COCI22_kemija) | C++17 | 1 ms | 340 KB |
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; while(n--){ string s; cin >> s; vector<pair<string, int>> vect1; vector<pair<string, int>> vect2; int pos=0; for(int i=0; i<s.size(); i++){ if(int(s[i])-int('0')<10 && int(s[i])-int('0')>0){ vect1.push_back({"", int(s[i])-int('0')}); i++; } else{ vect1.push_back({"", 1}); } string temp = ""; while(s[i]!='+' && s[i]!='-'){ temp+=s[i]; i++; } vect1.back().first=temp; if(s[i]=='-'){ pos=i+2; break; } } for(int i=pos; i<s.size(); i++){ if(int(s[i])-int('0')<10 && int(s[i])-int('0')>0){ vect2.push_back({"", int(s[i])-int('0')}); i++; } else{ vect2.push_back({"", 1}); } string temp = ""; while(i<s.size() && s[i]!='+' && s[i]!='-'){ temp+=s[i]; i++; } vect2.back().first=temp; if(s[i]=='-'){ pos=i+2; break; } } int ffirst[26]={0}; int ssecond[26]={0}; for(auto u : vect1){ string curs = u.first; int mul = u.second; for(int i=0; i<curs.size(); i++){ int temp = 1; if(i!=curs.size()-1 && int(curs[i+1])-int('0')<10 && int(curs[i+1])-int('0')>0){ temp=int(curs[i+1])-int('0'); } ffirst[int(curs[i])-int('A')]+=temp*mul; if(temp!=1){ i++; } } } for(auto u : vect2){ string curs = u.first; int mul = u.second; for(int i=0; i<curs.size(); i++){ int temp = 1; if(i!=curs.size()-1 && int(curs[i+1])-int('0')<10 && int(curs[i+1])-int('0')>0){ temp=int(curs[i+1])-int('0'); } ssecond[int(curs[i])-int('A')]+=temp*mul; if(temp!=1){ i++; } } } bool res = true; for(int i=0; i<26; i++){ if(ffirst[i]!=ssecond[i]){ res=false; break; } } if(res){ cout << "DA\n"; } else{ cout << "NE\n"; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 324 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 324 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 316 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |