Hi; I am trying to use std::cin.readsome()
for very fast input. Unfortunately the solution is working on my terminal but not on some judging servers. The same solutions transated to fread()
from cstdio
worked perfectly…
namespace FI {
const int L = 1 << 15 | 1;
char buf[L], *front, *back;
void nextChar(char &);
template <typename T>void nextNumber(T &);
}
void FI::nextChar(char &c) {
if(front == back) std::cin.readsome(buf, L), back = (front=buf) + std::cin.gcount();
c = !std::cin.gcount() ? (char)EOF : *front++;
}
template<typename T>void FI::nextNumber(T &x) {
char c; int f = 1;
for(nextChar(c); c>'9'||c<'0'; nextChar(c)) if(c == '-') f = -1;
for(x=0; c>='0'&& c<='9'; nextChar(c)) x = x*10+c-'0';
x *= f;
}