problemscpp
A collection of my answers to algorithm problems in c++.
函数
pat::b::b1090 命名空间参考

1090 危险品装箱 更多...

函数

int main (istream &cin, ostream &cout)
 
 TEST (b1089, case1)
 

详细描述

1090 危险品装箱

函数说明

◆ main()

int pat::b::b1090::main ( istream &  cin,
ostream &  cout 
)

在文件 pat.cpp3153 行定义.

3153 {
3154 int n;
3155 int m;
3156 cin >> n >> m;
3157 unordered_map<string, unordered_set<string>> um;
3158 for(int i = 0; i < n; i++) {
3159 string a;
3160 string b;
3161 cin >> a >> b;
3162 um[a].insert(b);
3163 um[b].insert(a);
3164 }
3165 for(int i = 0; i < m; i++) {
3166 int k;
3167 cin >> k;
3168 bool ok = true;
3169 unordered_set<string> us;
3170 for(int j = 0; j < k; j++) {
3171 string g;
3172 cin >> g;
3173 us.insert(g);
3174 }
3175 for(const auto &g: us) {
3176 for(const auto &nc: um[g]) {
3177 if(static_cast<unsigned int>(us.contains(nc)) != 0U) {
3178 ok = false;
3179 break;
3180 }
3181 }
3182 if(!ok) {
3183 break;
3184 }
3185 }
3186 if(ok) {
3187 cout << "Yes" << endl;
3188 } else {
3189 cout << "No" << endl;
3190 }
3191 }
3192 return 0;
3193 }

被这些函数引用 TEST().

◆ TEST()

pat::b::b1090::TEST ( b1089  ,
case1   
)

在文件 pat_test.cpp1574 行定义.

1574 {
1575 istringstream in("6 3\n"
1576 "20001 20002\n"
1577 "20003 20004\n"
1578 "20005 20006\n"
1579 "20003 20001\n"
1580 "20005 20004\n"
1581 "20004 20006\n"
1582 "4 00001 20004 00002 20003\n"
1583 "5 98823 20002 20003 20006 10010\n"
1584 "3 12345 67890 23333");
1585 auto out = ostringstream();
1586 main(in, out);
1587 const auto ans = out.str();
1588 ASSERT_EQ("No\n"
1589 "Yes\n"
1590 "Yes\n",
1591 out.str());
1592 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().