全体起立,0ms
2024-06-30 17:06:42
发布于:浙江
13阅读
0回复
0点赞
思路
先看题哈,发现有一个序号,且序号有序,那么.....
用map替换sort将排序改为查找,接着由于除去了一个序号,只剩了三个字符串,用string数组即可
废话少叙,直接上代码:
#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<map>
using namespace std;
int main() {
ios::sync_with_stdio(false);//cin,cout取消缓冲区,进行优化 cin和cout
cin.tie(0), cout.tie(0);//取消cin,cout绑定
int n;
cin >> n;
map<int, string[5]> mp;
for (int i = 1; i <= n; ++i) {
int a, b;
string c;
cin >> a >> b >> c;
mp[a][b] = c;
}
for (int i = 1; i <= n; ++i) {
int a, b;
string c;
cin >> a >> b >> c;
mp[a][b] = c;
}
for (int i = 1; i <= n; ++i) {
int a, b;
string c;
cin >> a >> b >> c;
mp[a][b] = c;
}//有人聪明的把三个循环合并,但其实三个循环拆开效率会更快
for (int i = 1; i <= n; ++i) {
cout << i << " " << mp[i][2] << " " << mp[i][3] << " " << mp[i][4] << endl;
}
return 0;
}
全部评论 1
哦,对了,感谢大家的观看,赶紧走开,不要回来!(狗子音)
2024-06-30 来自 浙江
0
有帮助,赞一个