当你用上了所有卡常技术想0ms一个普及-
2024-06-30 16:26:23
发布于:浙江
30阅读
0回复
0点赞
但是一直是1ms!!!气死我了!!!:(
哎,上代码吧
#pragma G++ optimize(1)
#pragma G++ optimize(2)
#pragma G++ optimize(3)
#pragma G++ optimize("Ofast")
#pragma G++ optimize("inline")
#pragma G++ optimize("-fgcse")
#pragma G++ optimize("-fgcse-lm")
#pragma G++ optimize("-fipa-sra")
#pragma G++ optimize("-ftree-pre")
#pragma G++ optimize("-ftree-vrp")
#pragma G++ optimize("-fpeephole2")
#pragma G++ optimize("-ffast-math")
#pragma G++ optimize("-fsched-spec")
#pragma G++ optimize("unroll-loops")
#pragma G++ optimize("-falign-jumps")
#pragma G++ optimize("-falign-loops")
#pragma G++ optimize("-falign-labels")
#pragma G++ optimize("-fdevirtualize")
#pragma G++ optimize("-fcaller-saves")
#pragma G++ optimize("-fcrossjumping")
#pragma G++ optimize("-fthread-jumps")
#pragma G++ optimize("-funroll-loops")
#pragma G++ optimize("-fwhole-program")
#pragma G++ optimize("-freorder-blocks")
#pragma G++ optimize("-fschedule-insns")
#pragma G++ optimize("inline-functions")
#pragma G++ optimize("-ftree-tail-merge")
#pragma G++ optimize("-fschedule-insns2")
#pragma G++ optimize("-fstrict-aliasing")
#pragma G++ optimize("-fstrict-overflow")
#pragma G++ optimize("-falign-functions")
#pragma G++ optimize("-fcse-skip-blocks")
#pragma G++ optimize("-fcse-follow-jumps")
#pragma G++ optimize("-fsched-interblock")
#pragma G++ optimize("-fpartial-inlining")
#pragma G++ optimize("no-stack-protector")
#pragma G++ optimize("-freorder-functions")
#pragma G++ optimize("-findirect-inlining")
#pragma G++ optimize("-frerun-cse-after-loop")
#pragma G++ optimize("inline-small-functions")
#pragma G++ optimize("-finline-small-functions")
#pragma G++ optimize("-ftree-switch-conversion")
#pragma G++ optimize("-foptimize-sibling-calls")
#pragma G++ optimize("-fexpensive-optimizations")
#pragma G++ optimize("-funsafe-loop-optimizations")
#pragma G++ optimize("inline-functions-called-once")
#pragma G++ optimize("-fdelete-null-pointer-checks")
//火车头,不推荐用,一个#pragma G++ optimize(3)应该就够了(O3优化)
//对了,某谷好像不欢迎pragma,天天爆编译错误
#include <iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}//整型快读
int main() {
struct Node {
string id, bm;
short s = 0;
};//Node直接塞主函数里
short n=read(), m=read();//short相对int可以减一半计算量
unordered_map<int, Node> mp;//不用数组+sort,
//用了unordered_map,查找效率比map还快些,但有的领域不如map
for (register short i = 1; i <= n; ++i/*比i++快*/) {
// register 把变量放寄存器里,不建议用,要用就放大规模循环里,否则可能有负优化
int a=read();
string b,c;
cin>>b>>c;
mp[a] = {b,c, 0};
}
while (m--) {
short tmp=read(), ti=read();
if (ti > 9)++mp[tmp].s;
}
for (register short i = 1; i <= n; ++i)
cout << i << " " << mp[i].id << " " << mp[i].bm << " " << mp[i].s << '\n';
}
你们有兴趣的可以试试,看看有没有欧皇0ms
好,本期题解到此结束,不要回来!(狗子音)
全部评论 3
但为什么ios::sync_with_stdio(0)不行
2024-07-01 来自 广东
0快读大概会比取消缓冲还快一点的,用快读更保险0ms
2024-07-01 来自 浙江
0加了这个全WA
2024-07-02 来自 广东
0不科学啊?!我AC了呀
2024-07-06 来自 浙江
0
可以用cin.tie(0) cout.tie(0)
2024-07-01 来自 广东
0so fast!
2024-07-01 来自 广东
0
有帮助,赞一个