답안 #1003203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003203 2024-06-20T07:45:56 Z ulianamalanyak Kemija (COCI22_kemija) C++14
50 / 50
1 ms 440 KB
#include "bits/stdc++.h"

using namespace std;

#define endl '\n'
#define INF 1000000000000

typedef int ll;

const int DIM=1e3+7;

ll n,m;
string s;
map<char,ll> m1,m2;

int main()
{
    //freopen ("input.txt","r",stdin);
    //freopen ("output.txt","w",stdout);
    
    cin >> m;

	while(m--)
	{
		cin >> s;

		m1.clear();
		m2.clear();
		n=s.size();

		bool fl=0;

		for (int i=0;i<n;i++)
		{
			ll mult;
			if (s[i]>='0'&&s[i]<='9') 
			{
				mult=s[i]-'0';
				i++;
			}
			else mult=1;
			
			while(i<n&&s[i]!='+'&&s[i]!='-')
			{
				//cout << s[i] << fl << endl;

				char c=s[i];
				
				ll mult1;
				if (i+1<n&&s[i+1]>='0'&&s[i+1]<='9')
				{
					mult1=s[i+1]-'0';
					i++;
				}
				else mult1=1;

				ll kilk=mult*mult1;
				if (fl)
				{
					m2[c]+=kilk;
					//cout << m2[c] << endl;
				}
				else 
				{
					m1[c]+=kilk;
					//cout << m1[c] << endl;
				}

				i++;
			}

			if (i>=n) continue;
			if (s[i]=='+') 
			{
				continue;
			}
			else if (s[i]=='-')
			{
				i++;
				fl=1;
			}
			else i++;
		}

		if (m1.size()!=m2.size()) cout << "NE" << endl;
		else 
		{
			bool ff=0;
			for (auto x:m1)
			{
				if (x.second!=m2[x.first])
				{
					cout << "NE" << endl;
					ff=1;
					break;
				}
			}

			if (ff==0) cout << "DA" << endl;
		}
	}
  
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct