为什么关闭同步流导致编译失败?
  • 板块灌水区
  • 楼主AC_loveRealNewbie
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/8/20 12:49
  • 上次更新2023/11/3 02:29:18
查看原帖
为什么关闭同步流导致编译失败?
186472
AC_loveRealNewbie楼主2023/8/20 12:49
#include <bits/stdc++.h>
using namespace std;
char s[10000010];
int r, b, g, w;
int ans;
int main()
{
	
//	freopen("eliminate.in", "r", stdin);
//	freopen("eliminate.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s;
	int l = strlen(s) - 1;
	for(int i = 0; i <= l; i ++)
	{
		if(s[i] == 'R')
			r ++;
		else if(s[i] == 'B')
			b ++;
		else
			g ++;
		if(r + w == 3 || b + w == 3 || g + w == 3)
		{
			r = 0;
			b = 0;
			g = 0;
			w = 1;
			ans ++;
		}
		if((r + w >= 1 && b >= 1 && g >= 1) || (r >= 1 && b + w >= 1 && g >= 1) || (r >= 1 && b >= 1 && g + w >= 1))
		{
			if(i == l)
			{
				cout << ans;
				return 0;
			}
			w = 0;
			r = 0;
			b = 0;
			g = 0;
			ans ++;
			i ++;
		}
	}
	cout << ans;
	return 0;
}
terminate called after throwing an instance of 'std::ios_base::failure'
  what():  basic_filebuf::underflow error reading the file

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

--------------------------------
Process exited after 2.18 seconds with return value 3
请按任意键继续. . .
2023/8/20 12:49
加载中...