답안 #767547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767547 2023-06-26T20:31:19 Z Username4132 Kemija (COCI22_kemija) C++14
50 / 50
1 ms 328 KB
#include<iostream>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)

int n, cou[26];
string str;

void process(int l, int r){
    int num = 1;
    if(str[l]>='1' && str[l]<='9') num = str[l++]-'0';
    while(l<r){
        int ind = str[l]-'A', mul = 1, nxt = l+1;
        if(l+1 < r && str[l+1]>='1' && str[l+1]<='9') mul = str[l+1] - '0', ++nxt;
        cou[ind]+=mul*num;
        l = nxt;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    forn(qnum, n){
        cin >> str;
        int l=0, r=0;
        while(l<(int)str.size()){
            while(r<(int)str.size() && str[r]!='+' && str[r]!='-') ++r;
            process(l, r);
            if(r<(int)str.size() && str[r]=='-'){
                r++;
                forn(i, 26) cou[i]=-cou[i];
            }
            l=r+1;
            r+=2;
        }
        bool flag=true;
        forn(i, 26) flag&=!cou[i], cou[i]=0;
        cout << (flag? "DA\n" : "NE\n");
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 324 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 324 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 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 1 ms 212 KB Output is correct
24 Correct 1 ms 212 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 212 KB Output is correct