华为机试0518 扑克牌整理机器人
傻瓜暴力版,求大佬指点
void test11() { vector<vector<int>> in = { {1,2}, {1,3}, {1,4}, {1,12}, {2,2}, {2,3}, {3,6},//6 {3,7}, {3,8}, {3,9}, {4,10},//10 {4,2}, {3,2}, {4,13} }; map<vector<int>, bool> sp; for (int i = 0; i < 14; ++i) { sp.insert(make_pair(in[i],true)); } int count = 0; for (int i = 1; i < 14; ++i) { for (int j = 1; j < 5; ++j) { if (sp.find({ j,i }) == sp.end()) { count = 0; break; } else { count++; if (count == 4) { for (int k = 1; k < 5; ++k) { cout << k << " " << i << endl; sp.erase({ k,i }); } count = 0; } } } } for (int i = 1; i < 14; ++i) { for (int j = 1; j < 5; ++j) { if (sp.find({ j,i }) == sp.end()) { count = 0; } else { count++; if (count == 2) { for (int k = 1; k < 5; ++k) { if (sp.find({ k,i }) != sp.end()) { cout << k << " " << i << endl; sp.erase({ k,i }); } } count = 0; } } } } for (int i = 1; i < 14; ++i) { for (int j = 1; j < 5; ++j) { if (sp.find({ j,i }) != sp.end()) { cout << j << " " << i << endl; } } } }