题解 2B
作者:互联网
明显的贪心,测评姬鬼畜了没了五分
Code:
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define N 100010
#define ll long long
#define reg register int
//#define int long long
int n;
char s[N], sta[N], tem[N];
signed main()
{
freopen("apstr.in", "r", stdin);
freopen("apstr.out", "w", stdout);
scanf("%s", s+1); n=strlen(s+1);
int pos1=0, pos2=1;
for (; pos2<=n; ++pos2) {
if (s[pos2]=='P' && pos1 && sta[pos1]=='A') --pos1;
else sta[++pos1]=s[pos2];
}
// cout<<"pos1: "<<pos1<<endl;
n=pos1; pos1=0; pos2=1;
for (; pos2<=n; ++pos2) {
if (sta[pos2]=='P' && pos1 && tem[pos1]=='P') --pos1;
else tem[++pos1]=sta[pos2];
}
printf("%d\n", pos1);
return 0;
}
标签:freopen,int,题解,long,2B,apstr,pos2,define 来源: https://www.cnblogs.com/narration/p/15314923.html