http://118.190.20.162/view.page?gpid=T50
把权限对应到每一个用户中去
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
struct T{
map<string,int> t;
};
struct V{
vector<string> t;
};
map<string,T> all;
map<string,int> AA;
map<string,V> rol;
int main()
{
string str;
int n;
cin >> n;
while (n--) {//AA
cin >> str;
int indx = str.find(':');
if (indx != string::npos)
AA[string(str, 0, indx)]=str[indx + 1] - '0';
else
AA[str] = -1;
}
cin >> n;
int nu;
string str2;
while (n--) {//role
cin >> str >> nu;
while (nu--) {
cin >> str2;
rol[str].t.push_back(str2);
}
}
cin >> n;
while (n--) {
cin >> str>>nu;
while (nu--) {
cin >> str2;
for (vector<string>::iterator it = rol[str2].t.begin();
it != rol[str2].t.end(); ++it) {
int indx = it->find(':');
if (indx != string::npos) {
if(all[string(*it, 0, indx)].t[str]<(*it)[indx + 1] - '0' + 1)
all[string(*it, 0, indx)].t[str]=(*it)[indx + 1] - '0' + 1;
}
else
all[*it].t[str] = -1;
}
}
}
cin >> n;
string _nam;
int _le;
while (n--) {
cin >> str >> str2;
int indx = str2.find(':');
if (indx != string::npos) {
_nam = string(str2, 0, indx);
_le = str2[indx + 1] - '0' + 1;
}
else {
_nam = str2;
_le = -1;
}
if (!all[_nam].t[str] || _le > all[_nam].t[str]) { cout << "false" << endl; }
else if (AA[_nam] != -1 && _le == -1) {
if (all[_nam].t[str])
cout << all[_nam].t[str] - 1 << endl;
else
cout << "false" << endl;
}
else cout << "true" << endl;
}
return 0;
}