鱨鱳集训第榹天晚上
T1:
打了接近两个小时,结果不知道为什么RE了,还不如直接输出V或F。
#include
using namespace std;
string s;
int len;
bool ans, cnt1, cnt2;
char op;
stack s1;
stack s2;
int youxian(char op) {
if (op == '!')
return 4;
if (op == '&')
return 3;
if (op == '|')
return 2;
if (op == '(')
return 1;
return 0;
}
void xiaojisuan() {
op = s2.top();
s2.pop();
if (op == '!') {
cnt1 = s1.top();
s1.pop();
s1.push(!cnt1);
} else if (op == '&') {
cnt1 = s1.top();
s1.pop();
cnt2 = s1.top();
s1.pop();
s1.push(cnt1 && cnt2);
} else if (op == '|') {
cnt1 = s1.top();
s1.pop();
cnt2 = s1.top();
s1.pop();
s1.push(cnt1 || cnt2);
}
}
bool dajisuan() {
for (int i = 0; i = youxian(ch)) xiaojisuan();
s2.push(ch);
} else if (ch == '(')
s2.push(ch);
else if (ch == ')') {
while (!s2.empty() && s2.top() != '(') xiaojisuan();
s2.pop();
}
}
while (!s2.empty()) xiaojisuan();
return s1.top();
}
int main() {
freopen("boolean.in", "r", stdin);
freopen("boolean.out", "w", stdout);
getline(cin, s);
len = s.size();
ans = dajisuan();
cout << (ans ? "V" : "F");
return 0;
}
T2:
暴力代码,直接AC
#include
using namespace std;
string s1, s2;
int n, k, cnt, idx, ans;
int main() {
freopen("master.in", "r", stdin);
freopen("master.out", "w", stdout);
cin >> n >> k >> s1 >> s2;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= n; j++) {
cnt = idx = 0;
for (int l = 1; l = k)
break;
idx++;
}
cnt++;
}
ans = max(ans, cnt);
}
}
cout << ans;
return 0;
}
T3:
骗分,一分不得
#include
using namespace std;
int n, m;
int main() {
freopen("starless.in", "r", stdin);
freopen("starless.out", "w", stdout);
cin >> n >> m;
cout << n << " " << n * (n - 1);
return 0;
}
《玄学骗分》
T4:
只为第一个子任务,拿下40分
#include
using namespace std;
int f[5005][5005], len1, len2;
string s1, s2;
int main() {
freopen("lcs.in", "r", stdin);
freopen("lcs.out", "w", stdout);
cin >> s1 >> s2;
len1 = s1.size(), len2 = s2.size();
for (int i = 1; i < len1; i++) {
for (int j = 1; j < len2; j++) {
f[i][j] = max(f[i - 1][j], f[i][j - 1]);
if (s1[i - 1] == s2[j - 1])
f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
}
}
cout << f[len1 - 1][len2 - 1] << '\n';
cout << 88;
return 0;
}
0+100+0+40=140分