#include<iostream> #include<string> usingnamespace std; intmain(){ int n, m; cin >> n >> m; string s; for (int i = 0; i < n; i++) { cin >> s; int count = 0; bool valid = true;
for (char c : s) { if (c == 'S') { if (count == m) { valid = false; break; } count++; } elseif (c == 'X') { if (count == 0) { valid = false; break; } count--; } } if (valid && count != 0) { valid = false; } cout << (valid ? "YES" : "NO") << endl; } return0; }
intstringtoint(const string& s){ int num = 0; int sign = 1; int start = 0;
if (s[0] == '-') { sign = -1; start = 1; }
for (int i = start; i < s.length(); i++) { num = num * 10 + (s[i] - '0'); } return sign * num; }
intmain(){ string input; getline(cin, input);
stack<int> st;
string current = "";
for (int i = 0; i < input.length(); i++) { char c = input[i]; if (c == ' ') {// 如果遇到空格,处理当前current if (current.empty() != 1) { if (current == "+" || current == "-" || current == "*") { int right = st.top(); st.pop(); int left = st.top(); st.pop(); if (current == "+") { int result = left + right; st.push(result); } elseif (current == "-") { int result = left - right; st.push(result); } elseif (current == "*") { int result = left * right; st.push(result); } } else {// 如果是操作数 st.push(stringtoint(current)); } current = ""; } } else { current += c; } }
if (!current.empty()) { if (current == "+" || current == "-" || current == "*") { int right = st.top(); st.pop(); int left = st.top(); st.pop();