第二题(更新)
100分代码
#include <bits/stdc++.h>
using namespace std;
int s[55][55];
map<pair<int, int>, int>tree;
int main(){
int n, L, S;
cin >> n >> L >> S;
for(int i=0; i<n; i++){
int x,y;
cin >> x >> y;
tree[{x, y}] = 1;
}
for(int i=0; i<=S; i++){
for(int j=0; j<=S; j++){
cin >> s[S-i][j];
}
}
int ans=0;
for(auto it=tree.begin(); it!=tree.end(); it++){
int x = it->first.first;
int y = it->first.second;
int flag=0;
if(x+S>L || y+S>L)continue;
for(int i=0; i<=S; i++){
for(int j=0; j<=S; j++){
if((s[i][j] && !tree.count({x+i, y+j})) || (!s[i][j] && tree.count({x+i, y+j}))){
flag=1;
}
}
}
if(!flag)ans++;
}
cout << ans;
}
第三题
70分代码
写的可能有些繁琐,后面三个样例超时了
#include <bits/stdc++.h>
using namespace std;
struct Role{
string name;
vector<string>ops;
vector<string>res_k;
vector<string>res;
};
map<string, Role>role_con;
map<string, vector<string> >user_con;
int main(){
int n,m,q;
cin >> n >> m >> q;
for(int i=0; i<n; i++){
Role role;
string name;
cin >> name;
role.name = name;
int nv;
cin >> nv;
for(int j=0; j<nv; j++){
string ops;
cin >> ops;
role.ops.push_back(ops);
}
int no;
cin >> no;
for(int j=0; j<no; j++){
string res_k;
cin >> res_k;
role.res_k.push_back(res_k);
}
int nn;
cin >> nn;
for(int j=0; j<nn; j++){
string res;
cin >> res;
role.res.push_back(res);
}
role_con[name] = role;
}
for(int i=0; i<m; i++){
string name;
cin >> name;
int ns;
cin >> ns;
char t;string user;
for(int j=0; j<ns; j++){
cin >> t >> user;
user_con[user].push_back(name);
}
}
while(q--){
string user;
cin >> user;
int ng;
cin >> ng;
vector<string>zu;
for(int i=0; i<ng; i++){
string zuname;
cin >> zuname;
zu.push_back(zuname);
}
zu.push_back(user);
string ops,res_k,res;
cin >> ops >> res_k >> res;
int flag=0;
for(auto user : zu){
for(auto r_name : user_con[user]){
Role role = role_con[r_name];
for(auto _ops : role.ops){
if(_ops==ops || _ops=="*"){
for(auto _res_k : role.res_k){
if(_res_k == res_k||_res_k=="*"){
if(role.res.size()==0){
flag=1;
break;
}
for(auto _res : role.res){
if(_res == res){
flag=1;
break;
}
}
}
if(flag)break;
}
}
if(flag)break;
}
}
}
cout << flag << endl;
}
}






被折叠的 条评论
为什么被折叠?



