官方是不是不认ifstream和ofstream?
查看原帖
官方是不是不认ifstream和ofstream?
358777
xzsheng楼主2021/4/6 23:18

官方爆0。把ifstream/ofstream换成cin/cout,在洛谷就AC。看到其他人写的都是用freopen把文件重定向到cin/cout,是不是官方不认ifstream/ofstream

以下是提交到官方评测爆0的代码:

#include <fstream>
using namespace std;

int main()
{
	auto in = ifstream("cake.in");
	int t;
	in >> t;
	auto out = ofstream("cake.out");
	for (int i = 0; i < t; i++)
	{
		int a, b, c;
		in >> a >> b >> c;
		if (a == 0 && b == 0 || a == 0 && c == 0 || b == 0 && c == 0)
		{
			out << 0 << endl;
		}
		else if (a == 0 || b == 0 || c == 0)
		{
			if (a == b || b == c || a == c)
			{
				out << 1 << endl;
			}
			else
			{
				out << 2 << endl;
			}
		}
		else
		{
			if (a == b || b == c || a == c)
			{
				out << 2 << endl;
			}
			else if (a + b == c || a + c == b || b + c == a)
			{
				out << 2 << endl;
			}
			else
			{
				out << 3 << endl;
			}
		}
	}
	
	return 0;
}
2021/4/6 23:18
加载中...