std::ios::sync_with_stdio(false);
加了这句cin cout就能和scanf差不多速度,但是加了这句就不能用scanf和printf
#pragma comment(linker, "/STACK:1024000000,1024000000")
汇编开栈:
int size = 256 << 20; // 256MB
char *p = (char*)malloc(size) + size;
__asm__("movl %0, %%esp\n" :: "r"(p));
C fread读写挂
//
const int MAXBUF = 10000;
char buf[MAXBUF], *ps = buf, *pe = buf + 1;
inline void rnext()
{
if (++ps == pe)
pe = (ps = buf) + fread(buf, sizeof(char), sizeof(buf) / sizeof(char), stdin);
}
template <class T>
inline bool rd(T &ans)
{
ans = 0;
T f = 1;
if (ps == pe) return false;//EOF
do {
rnext();
if ('-' == *ps) f = -1;
} while (!isdigit(*ps) && ps != pe);
if (ps == pe) return false;//EOF
do
{
ans = (ans << 1) + (ans << 3) + *ps - 48;
rnext();
} while (isdigit(*ps) && ps != pe);
ans *= f;
return true;
}
const int MAXOUT = 100000;
char bufout[MAXOUT], outtmp[50], *pout = bufout, *pend = bufout + MAXOUT;
inline void write()
{
fwrite(bufout, sizeof(char), pout - bufout, stdout);
pout = bufout;
}
inline void out_char(char c) { *(pout++) = c;if (pout == pend) write(); }
inline void out_str(char *s) {
while (*s) {
*(pout++) = *(s++);
if (pout == pend) write();
}
}
template <class T>
inline void pt(T x) {
if (!x) {
out_char('0');
return;
}
if (x < 0) x = -x, out_char('-');
int len = 0;
while (x) {
outtmp[len++] = x % 10 + 48;
x /= 10;
}
outtmp[len] = 0;
for (int i = 0, j = len - 1; i < j; i++, j--) swap(outtmp[i], outtmp[j]);
out_str(outtmp);
}
//在int main(){ write();return 0;}return 0;前一句一定要写write();
/*demo: 一旦使用pt要注意的三件事 1:要加write 2:不能使用别的任何输出语句 如puts putchar cout printf等 3:输出的文件大小不能超过MAXOUT
int main() {
int n; rd(n); pt(n);
write(); return 0;
}*/
C读写外挂:
template <class T>
inline bool rd(T &ret) {
char c; int sgn;
if(c=getchar(),c==EOF) return 0;
while(c!='-'&&(c<'0'||c>'9')) c=getchar();
sgn=(c=='-')?-1:1;
ret=(c=='-')?0:(c-'0');
while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
ret*=sgn;
return 1;
}
template <class T>
inline void pt(T x) {
if (x <0) {
putchar('-');
x = -x;
}
if(x>9) pt(x/10);
putchar(x%10+'0');
}
计时黑科技:
clock_t lim = clock() + 1.9*CLOCKS_PER_SEC;//2s 所以设置上限是1.9
if (clock() >= lim)break;
java读写外挂:点击打开链接
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class Scanner {