提交记录 17785


用户 题目 状态 得分 用时 内存 语言 代码长度
imalyd 1000i. 【传统题】 A+B Problem Accepted 100 15.43 us 28 KB C++ 3.67 KB
提交时间 评测时间
2022-07-10 23:25:21 2022-07-10 23:25:22
#pragma GCC optimize("Ofast,unroll-loops")
#include <cstdio>
#pragma GCC optimize(3)

namespace yaCachedTextIO
{
	template <std::size_t bufferLength = 1 << 20>
	class cachedTextInput
	{
		std::FILE *inputFile;
		char buffer[bufferLength], *bufferStart, *bufferEnd, currentCharacter;
		bool signedFlag;

		inline void _gc()
		{
			if (bufferStart == bufferEnd)
			{
				bufferEnd = (bufferStart = buffer) + std::fread(buffer, 1, bufferLength, inputFile);
				currentCharacter = bufferStart == bufferEnd ? EOF : *bufferStart++;
			}
			else
				currentCharacter = *bufferStart++;
		}

	public:
		inline cachedTextInput(std::FILE *_inputFile = stdin) : inputFile(_inputFile), bufferStart(NULL), bufferEnd(NULL) {}

		template <typename unsignedIntegerType>
		inline void getUnsignedDecimalInteger(register unsignedIntegerType &x)
		{
			x = 0;
			_gc();
			while (currentCharacter < '0' || currentCharacter > '9')
				_gc();
			while ('0' <= currentCharacter && currentCharacter <= '9')
			{
				x = (x << 1) + (x << 3) + (currentCharacter ^ '0');
				_gc();
			}
		}

		template <typename signedIntegerType>
		inline void getSignedDecimalInteger(register signedIntegerType &x)
		{
			x = 0;
			signedFlag = false;
			_gc();
			while (currentCharacter < '0' || currentCharacter > '9')
			{
				if (currentCharacter == '-')
					signedFlag = true;
				_gc();
			}
			while ('0' <= currentCharacter && currentCharacter <= '9')
			{
				x = (x << 1) + (x << 3) + (currentCharacter ^ 48);
				_gc();
			}
			if (signedFlag)
				x = -x;
		}
	};

	template <std::size_t bufferLength = 1 << 20, std::size_t temporaryBufferLength = 256>
	class cachedTextOutput
	{
		std::FILE *outputFile;
		char buffer[bufferLength], *bufferLimit, *bufferEnd;
		char temporaryBuffer[temporaryBufferLength], *temporaryBufferLimit, *temporaryBufferEnd;

		inline void _flush()
		{
			std::fwrite(buffer, 1, bufferEnd - buffer, outputFile);
			bufferEnd = buffer;
		}

		inline void _pc(register const char &currentCharacter)
		{
			if (bufferEnd == bufferLimit)
				_flush();
			*bufferEnd++ = currentCharacter;
		}

		inline void _flushTmp()
		{
			while (temporaryBufferEnd != temporaryBuffer)
				_pc(*--temporaryBufferEnd);
		}

	public:
		inline cachedTextOutput(std::FILE *_outputFile = stdout) : outputFile(_outputFile), bufferEnd(buffer), bufferLimit(buffer + bufferLength), temporaryBufferEnd(temporaryBuffer), temporaryBufferLimit(temporaryBuffer + temporaryBufferLength) {}

		inline ~cachedTextOutput()
		{
			_flush();
		}

		inline void putCharacter(const char &c)
		{
			_pc(c);
		}

		template <typename unsignedIntegerType>
		inline void putUnsignedDecimalInteger(register unsignedIntegerType x)
		{
			unsignedIntegerType tmp;
			do
			{
				tmp = x / 10;
				*temporaryBufferEnd++ = ((x - ((tmp << 1) + (tmp << 3))) ^ '0');
				x = tmp;
			} while (x);
			_flushTmp();
		}

		template <typename signedIntegerType>
		inline void putSignedDecimalInteger(register signedIntegerType x)
		{
			if (x < 0)
			{
				x = -x;
				_pc('-');
			}
			putUnsignedDecimalInteger(x);
		}

		inline void putSpace()
		{
			_pc(' ');
		}

		inline void putLine()
		{
			_pc('\n');
		}
	};
};

namespace yaCode
{
	using yaCachedTextIO::cachedTextInput;
	using yaCachedTextIO::cachedTextOutput;
};

using namespace yaCode;

cachedTextInput<1500> _cachedTextInput;

#define in(x) _cachedTextInput.getSignedDecimalInteger((x))

cachedTextOutput<1500, 10> _cachedTextOutput;

#define ou(x) _cachedTextOutput.putSignedDecimalInteger((x))
#define ousp(x) _cachedTextOutput.putSignedDecimalInteger((x)), _cachedTextOutput.putSpace()
#define ouln _cachedTextOutput.putLine()

int main()
{
	register int n, a, b;
	in(n);
	while (n--)
	{
		in(a);
		in(b);
		ou(a + b);
		ouln;
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #115.43 us28 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-04 00:39:45 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用