답안 #799993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799993 2023-08-01T09:11:55 Z Tunglam07 Kemija (COCI22_kemija) C++17
50 / 50
1 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
	 
int main()
{
	long long t, save, cnt[27], id;
	bool ck;
	string s;
	cin >> t;
	memset(cnt, 0, sizeof(cnt));
	while(t--)
	{
		save = 1;
		ck = 0;
		cin >> s;
		for(int i = 0; i < s.size(); i++)
		{
			if(ck == 0 && s[i] >= 48 && s[i] <= 57)
			{
				save = s[i] - 48;
				ck = 1;
			}
			else if(s[i] >= 48 && s[i] <= 57)	
			{
				cnt[s[i - 1] - 65] += ((s[i] - 49) * save);
			}
			else if(s[i] > 64 && s[i] < 91)
			{
				cnt[s[i] - 65] += save;
				ck = 1;
			}
			else if(s[i] == 43)
			{
				ck = 0;
				save = 1;
			}
			else if(s[i] == 45 && s[i + 1] == 62)
			{
				id = i + 2;
				break;
			}
		}
		ck = 0;
		save = 1;
		for(int i = id; i < s.size(); i++)
		{
			if(ck == 0 && s[i] >= 48 && s[i] <= 57)
			{
				save = s[i] - 48;
				ck = 1;
			}
			else if(s[i] >= 48 && s[i] <= 57)	
			{
				cnt[s[i - 1] - 65] -= (s[i] - 49) * save;
			}
			else if(s[i] > 64 && s[i] < 91)
			{
				cnt[s[i] - 65] -= save;
				ck = 1;
			}
			else if(s[i] == 43)
			{
				ck = 0;
				save = 1;
			}
		}
		ck = 0;
		for(int i = 0; i < 26; i++)
		{
			if(cnt[i])
			{
				ck = 1;
			}
			cnt[i] = 0;
		}
		if(ck)	
		{
			cout << "NE" << endl;
		}
		else	
		{
			cout << "DA" << endl;
		}
	}
}

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:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i = id; i < s.size(); i++)
      |                   ~~^~~~~~~~~~
Main.cpp:45:11: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |   for(int i = id; i < s.size(); i++)
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 296 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 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 296 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 300 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 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 296 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 296 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 300 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 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 300 KB Output is correct