为什么运行时错误
  • 板块灌水区
  • 楼主chty
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/10/13 13:57
  • 上次更新2024/10/13 15:50:23
查看原帖
为什么运行时错误
1162593
chty楼主2024/10/13 13:57

qwq

#include<bits/stdc++.h>
using namespace std;
int arr[200005];
int main() {
	int n;
	cin>>n;
	string m;
	cin>>m;
	stack<char> s;
	stack<int> s1;
	for(int i=0; i<n; i++) {
		int k=s.top();
		if(k!=(int)m[i]) {
			cout<<1;
			s.push((char)m[i]);
			cout<<1;
			s1.push(i);
		} else {
			s.pop();
			int k=s1.top();
			arr[i+1]=arr[k]+1;
		}
	}
	int ans=0;
	for(int i=1; i<=n; i++) {
		ans+=arr[i];
	}
	cout<<ans;
}
2024/10/13 13:57
加载中...