답안 #639291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639291 2022-09-09T10:50:37 Z NotLinux Kemija (COCI22_kemija) C++14
50 / 50
1 ms 340 KB
/**
 * author: NotLinux
 * created: 09.09.2022 ~ 13:22:10
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
    #include "/home/notlinux/debug.h"
#else
    #define debug(x...) void(37)
#endif
vector < int > procces2(string str){
    vector < int > result2(26,0LL);
    int kat = 1;
    if(str[0]>='2' and str[0]<='9')kat = str[0]-'0';
    for(int i = 0;i<(int)str.size();i++){
        if(str[i]>='A' and str[i]<='Z'){
            int kat2 = 1;
            if(i!=((int)str.size()-1) and (str[i+1]>='1' and str[i+1]<='9')){
                kat2 = str[i+1]-'0';
            }
            result2[str[i]-'A'] += kat2;
        }
    }
    for(int i = 0;i<26;i++)result2[i]*=kat;
    return result2;
}
vector < int > procces(string str){
    str += '+';
    vector < int > result(26,0LL);
    int left = 0;
    for(int i = 0;i<(int)str.size();i++){
        if(str[i] == '+'){
            vector < int > locresult = procces2(string(str.begin()+left,str.begin()+i));
            for(int i = 0;i<26;i++){
                result[i] += locresult[i];
            }
            left = i+1;
        }
    }
    return result;
}
void solve(){
    string eq;cin >> eq;
    int ind = 0;
    for(int i = 0;i<(int)eq.size();i++){
        if(eq[i] == '-'){
            ind = i;
            break;
        }
    }
    vector < int > left = procces(string(eq.begin() , eq.begin()+ind));
    vector < int > right = procces(string(eq.begin()+ind+2  , eq.end()));
    cout << (left == right ? "DA" : "NE") << endl;
}
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    int tt=1;
    cin >> tt;
    while(tt--)solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 316 KB Output is correct