Submission #704213

# Submission time Handle Problem Language Result Execution time Memory
704213 2023-03-02T00:34:09 Z AaW Kemija (COCI22_kemija) C++14
50 / 50
1 ms 324 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl '\n'
#define AI(x) begin(x),end(x)
#ifdef DEBUG 
#define debug(args...) LKJ("\033[1;32m[ "+string(#args)+" ]\033[0m", args)
template<class I> void LKJ(I&&x){ cerr << x << '\n'; }
template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr << x << ", ", LKJ(t...); }
template<class I> void OI(I a, I b){ while(a < b) cerr << *a << " \n"[next(a) == b], ++a; }
#else
#define debug(...) 0
#define OI(...) 0
#endif
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

signed main(){_
	int t;
	cin >> t;
	while(t--) {
		string s;
		cin >> s;
		vector<int> cnt(256,0);
		int mult = 1;		
		bool head = 1;
		bool front = 1;

		for (int i = 0; i < s.size(); ++i) {
			if (head) {
				if (s[i] >= '0' && s[i] <= '9'){
					mult = s[i] - '0';
					head = 0; 
					continue;
				}
				head = 0;
			}
			if (s[i] == '+') {
				head = 1;
				mult = 1;
				continue;
			}
			if (s[i] == '-' || s[i] == '>') {
				front = 0;
				head = 1;
				mult = 1;
				continue;
			}
			int ab = (front) ? 1 : -1;
			if (s[i] >= '0' && s[i] <= '9') {
				cnt[s[i-1]] += mult * ab * (s[i] - '0' - 1);
				continue;
			}
			cnt[s[i]] += mult * ab;
		}
		
		int flag = 1;
		for (auto i : cnt) {
			if (i != 0) {
				cout << "NE" << endl;
				flag = 0;
				break;
			}
		}
		if(flag) cout << "DA" << endl;

	}	

	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for (int i = 0; i < s.size(); ++i) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 312 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 0 ms 320 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 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 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct