警示后人
  • 板块灌水区
  • 楼主rainygame
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/10/22 06:30
  • 上次更新2023/11/2 12:02:59
查看原帖
警示后人
804607
rainygame楼主2023/10/22 06:30

我的 SB(S 组 B 题)代码:

#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, ans, flag;
string str;

signed main(){
	freopen("game.in", "r", stdin);
	freopen("game.out", "w", stdout);
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> str;
	str = ' ' + str;
	for (auto i: str){
		if (i != 'a' || i != 'b') flag = 1;
	}
	
	if (flag){
		cout << 0;
		return 0;
	}
	
	for (int l(1); l<=n; ++l){
		stack<char, vector<char>> st;
		for (int j(l); j<=n; ++j){
			if (st.empty() || st.top() != str[j]) st.push(str[j]);
			else st.pop();
			ans += st.empty();
		}
	}
	
	cout << ans;
	
	return 0;
}

0 分。因为 flag 必定为真。所以输出必为 0。所以考试快要结束时一定要好好测一遍样例。

如果把这坨东西给删掉,即有 5050 分。

没想到我是被这个搞走的……明年再见。

2023/10/22 06:30
加载中...