CSP-S T2 UB
  • 板块灌水区
  • 楼主yintaocheng
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/10/22 08:49
  • 上次更新2023/11/2 12:02:02
查看原帖
CSP-S T2 UB
623697
yintaocheng楼主2023/10/22 08:49

赛事暴力代码

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int s=0;
	bool f=false;
	char c=getchar();
	while(!isdigit(c))
	{
		f=(c=='-');
		c=getchar();
	}
	while(isdigit(c))
	{
		s=(s<<3)+(s<<1)+c-'0';
		c=getchar();
	}
	return f?-s:s;
}
void write(int x)
{
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	if(x>9)
	{
		write(x/10);
	}
	putchar(x%10+'0');
}
int n,ans=0;
string s;
stack<char>q;
inline void cl()
{
	while(!q.empty())
	{
		q.pop();
	}
}
signed main()
{
	//freopen("game.in","r",stdin);
	//freopen("game.out","w",stdout);
	n=read();
	getline(cin,s);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j+=2)
		{
			cl();
			for(int k=i;k<=j;k++)
			{
				if(q.empty())
				{
					q.push(s[k]);
				}
				else if(q.top()==s[k])
				{
					q.pop();
				}
				else
				{
					q.push(s[k]);
				}
			}
			if(q.empty())
			{
				ans++;
			}
		}
	}
	write(ans);
	return 0;
}

在小图灵上AC35分,剩下TLE,符合预期
在洛谷上WA35分,剩下RE
在n=read()后加上getchar()则与小图灵相同
应该是Windows系统与Linux系统换行符的区别
请问哪个是Linux的?

2023/10/22 08:49
加载中...