제출 #799497

#제출 시각아이디문제언어결과실행 시간메모리
799497tlnk07Kemija (COCI22_kemija)C++17
20 / 50
1 ms212 KiB
#include<bits/stdc++.h>
using namespace std;

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

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

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int i = 0; i < s.size(); ++i)
      |                  ~~^~~~~~~~~~
Main.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for(int i = pos; i < s.size(); ++i)
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...