欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 维修 > ccfcsp-202206(1、2、3)

ccfcsp-202206(1、2、3)

2024/10/24 22:30:57 来源:https://blog.csdn.net/weixin_51503393/article/details/141979272  浏览:    关键词:ccfcsp-202206(1、2、3)

202206-1 归一化处理

#include <bits/stdc++.h>
using namespace std;
int main() {int n;cin >> n;vector<double> vec(n);double ave = 0;for(int i = 0; i < n; i++){cin >> vec[i];ave += vec[i];}ave /= n;double vari = 0;for(int i = 0; i < n; i++){vari += (vec[i] - ave) * (vec[i] - ave);}vari /= n;for(int i = 0; i < n; i++){cout << (vec[i] - ave) / sqrt(vari) << endl;}return 0;
}

202206-2 寻宝!大冒险!

#include <bits/stdc++.h>
using namespace std;int main() {int n,l,s;cin >> n >> l >> s;set<pair<int,int>> mapset;set<pair<int,int>> treaset;vector<vector<int>> vec(s + 1,vector<int>(s + 1, 0));for(int i = 0; i < n; i++){int x,y;cin >> x >> y;mapset.insert({x,y});}for(int i = s; i >= 0; i--){for(int j = 0; j <= s; j++){cin >> vec[i][j];if(vec[i][j] == 1)treaset.insert({i,j});}}int ans = 0;for(auto it : mapset){if(it.first + s > l || it.second + s > l)//边界判断continue;int flag = 1;for(int i = 0; i <= s; i++){for(int j = 0; j <= s; j++){if(vec[i][j] == 1){if(mapset.find({i + it.first,j + it.second}) == mapset.end()){flag = 0;break;}}else{if(mapset.find({i + it.first,j + it.second}) != mapset.end()){flag = 0;break;}}}}if(flag)ans++;}cout << ans;return 0;
}

202206-3 角色授权

#include <bits/stdc++.h>
using namespace std;struct User{string username;unordered_set<string> mani_lst;unordered_set<string> res_type;unordered_set<string> res_name;
};int check(const User& chr, const string& mani, const string& type, const string& name){if (chr.mani_lst.count(mani) == 0 && chr.mani_lst.count("*") == 0)return 0;if (chr.res_type.count(type) == 0 && chr.res_type.count("*") == 0)return 0;if (chr.res_name.count(name) == 0 && !chr.res_name.empty())return 0;return 1;
}int main(){int n, m, q;cin >> n >> m >> q;map<string, User> role;for (int i = 0; i < n; i++){string chr;User chr_info;cin >> chr;int nv;cin >> nv;for (int iv = 0; iv < nv; iv++){string mani;cin >> mani;chr_info.mani_lst.insert(mani);}int no;cin >> no;for (int io = 0; io < no; io++){string type;cin >> type;chr_info.res_type.insert(type);}int nn;cin >> nn;for (int in = 0; in < nn; in++){string name;cin >> name;chr_info.res_name.insert(name);}role.insert({chr, chr_info});}multimap<string, string> rel_u;multimap<string, string> rel_g;for (int i = 0; i < m; i++){string chr;int ns;cin >> chr >> ns;for (int is = 0; is < ns; is++){string type, user, group;cin >> type;if (type == "u"){cin >> user;rel_u.insert(make_pair(user, chr));}else{cin >> group;rel_g.insert(make_pair(group, chr));}}}for (int i = 0; i < q; i++){string id, mani, type, name;int ng;cin >> id >> ng;string gr_lst[405];for (int ig = 0; ig < ng; ig++)cin >> gr_lst[ig];cin >> mani >> type >> name;auto range_u = rel_u.equal_range(id);for (auto it = range_u.first; it != range_u.second; it++){const string& rolename = it->second;const User& temp = role.find(rolename)->second;if (check(temp, mani, type, name) == 1){cout << 1 << endl;goto ending;}}for (int ig = 0; ig < ng; ig++){auto range_g = rel_g.equal_range(gr_lst[ig]);for (auto it = range_g.first; it != range_g.second; it++){const string& rolename = it->second;const User& temp = role.find(rolename)->second;if (check(temp, mani, type, name) == 1){cout << 1 << endl;goto ending;}}}cout << 0 << endl;ending:continue;}return 0;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com