星铁uid: ,求强力助战,求大佬加我。
胡桃厨。银狼厨。miku厨。天依厨。蒟蒻音游人。
一些实用工具:
对拍器
#include<iostream>
#include<Windows.h>
#include<time.h>
using namespace std;
int main() {
int id = 0;
while(1) {
system("gen.exe > test.in");
system("std.exe < test.in > std.out");
double bg = clock();
system("my.exe < test.in > my.out");
double ed = clock();
printf(">> test no.%d...\n", ++id);
if(system("fc std.out my.out")) {
break;
}
printf("cpu time is %.0lf ms\n\n", ed - bg);
}
return 0;
}常用颜色
你能认出她们是谁吗?
超级快读快写
支持:
-
连续读入、连续输出;
-
多类型混合读入、多类型混合输出;
-
int、long long、__int128、string、char类型变量快速读入; -
int、long long、__int128、string类型变量、字符串常量快速输出; -
连续输出时自定义分隔符。
#include<cstdio>
#define SUBMIT
namespace Hatsune {
#ifdef SUBMIT
#define SIZE (1<<22)
char in[SIZE], out[SIZE], *p1 = in, *p2 = in, *p3 = out;
#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,SIZE,stdin),p1==p2)?EOF:*p1++)
#define flush() (fwrite(out,1,p3-out,stdout),p3=out)
#define putchar(ch) (p3==out+SIZE&&flush(),*p3++=(ch))
class Flush { public:~Flush() { flush(); } }_;
#endif
namespace Miku {
inline void read(char &x) {
x = getchar();
while(x==' ' || x=='\n' || x=='\r' || x=='\t') x = getchar();
}
inline void read(string &x) {
x.clear(); char ch = getchar();
while(ch==' ' || ch=='\n' || ch=='\r' || ch=='\t') ch = getchar();
while(ch!=' ' && ch!='\n' && ch!='\r' && ch!='\t' && ch!=EOF)
x.push_back(ch), ch=getchar();
}
template<typename type>
inline void read(type& x) {
x = 0; bool flag(0); char ch = getchar();
while(ch < '0' || ch>'9') flag ^= ch == '-', ch = getchar();
while(ch >= '0' && ch <= '9') x = (x<<1)+(x<<3)+(ch^48), ch = getchar();
flag ? x = -x : 0;
}
template<typename type, typename ...T>
inline void read(type &x, T&...y) { read(x); read(y...); }
/*- read & write -*/
inline void _write(const char* x, bool flag) {
if (!x) return;
while (*x) putchar(*x++);
flag ? putchar('\n') : putchar(' ');
}
inline void _write(char* x, bool flag) { _write((const char*)x, flag); }
inline void _write(string &x, bool flag) {
for (char c : x) putchar(c);
flag ? putchar('\n') : putchar(' ');
}
template<typename type>
inline void _write(type x, bool flag) {
x < 0 ? x = -x, putchar('-') : 0; short Stack[50], top(0);
do Stack[++top] = x % 10, x /= 10; while (x);
while(top) putchar(Stack[top--] | 48);
flag ? putchar('\n') : putchar(' ');
}
inline void write() {}
template<typename type>
inline void write(type x) { _write(x, 1); }
template<typename type, typename ...T>
inline void write(type x, T...y) { _write(x, 0); write(y...); }
}
#ifdef SUBMIT
#undef SIZE
#undef getchar
#undef putchar
#undef flush
#endif
}using Hatsune::Miku::read; using Hatsune::Miku::write;链接
代码折叠框
洛谷的实现方式:
\:::info/success/warning/error[Your Title Here]
\```language
\```
\:::使用 HTML 标签的实现方式:
<details>
<summary><font color="" size="">Your Title Here</font></summary>
\```Language
\```
</details>memset 常用值
int & long long
“较”的原则:加法不爆。
极大值:0x7f
极小值:0x80
较大值:0x3f
较小值:0xc0
double
“较”的原则:保证一定位精度。
极大值:0x7f
极小值:0xfe
较大值:0x43
较小值:0xc2
缺省源
#include <bits/stdc++.h>
#ifdef _WIN32
#include <windows.h>
#include <psapi.h>
#else
#include <sys/resource.h>
#endif
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MIKU 0
using namespace std;
namespace YZWU {
void main() {
fastio;
return;
}
}
double peakMEM() {
#ifdef _WIN32
PROCESS_MEMORY_COUNTERS p;
GetProcessMemoryInfo(GetCurrentProcess(), &p, sizeof(p));
return p.PeakWorkingSetSize/1024.0/1024.0;
#else
rusage r; getrusage(RUSAGE_SELF, &r);
return r.ru_maxrss/1024.0;
#endif
}
signed main() {
auto st = chrono::steady_clock::now();
YZWU::main();
cerr<<"\nUse: "<<peakMEM()<<"MiB & "
<<chrono::duration<double, milli>(chrono::steady_clock::now()-st).count()<<"ms.\n";
return MIKU;
}