답안 #799485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799485 2023-07-31T15:07:02 Z tlnk07 Kemija (COCI22_kemija) C++17
20 / 50
1 ms 252 KB
#include<bits/stdc++.h>
using namespace std;

long long n, nho, cnt[101], chk, pos;
string s;

int main()
{
	cin >> n;
	memset(cnt, 0, sizeof(cnt));
	while(n--)
	{
		nho = 1;
		chk = 0;
		cin >> s;
		for(int i = 0; i < s.size(); ++i)
		{
			if(chk == 0 && s[i] >= '0' && s[i] <= '9')
			{
				nho = s[i] - '0';
				chk = true;
			}
			else if(s[i] >= '0' && s[i] <= '9')	cnt[s[i - 1] - 'A'] += ((s[i] - '1') * nho);
			else if(s[i] >= 'A' && s[i] <= 'Z')
			{
				cnt[s[i] - 'A'] += nho;
				chk = 1;
			}
			else if(s[i] == '+')	chk = 0;
			else if(s[i] == '-' && s[i + 1] == '>')
			{
				pos = i + 2;
				break;
			}
		}
		chk = 0;
		nho = 1;
		for(int i = pos; i < s.size(); ++i)
		{
			if(chk == 0 && s[i] >= '0' && s[i] <= '9')
			{
				nho = s[i] - '0';
				chk = true;
			}
			else if(s[i] >= '0' && s[i] <= '9')	cnt[s[i - 1] - 'A'] -= ((s[i] - '1') * nho);
			else if(s[i] >= 'A' && s[i] <= 'Z')
			{
				cnt[s[i] - 'A'] -= nho;
				chk = 1;
			}
			else if(s[i] == '+')	chk = 0;
		}
		chk = 0;
		for(int i = 0; i < 26; ++i)
		{
			if(cnt[i])	chk = true;
			cnt[i] = 0;
		}
		if(chk)	cout << "NE\n";
		else	cout << "DA\n";
	}
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int i = 0; i < s.size(); ++i)
      |                  ~~^~~~~~~~~~
Main.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for(int i = pos; i < s.size(); ++i)
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 252 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 252 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 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 Incorrect 1 ms 212 KB Output isn't correct
23 Halted 0 ms 0 KB -