Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
88814 sh25_zhangyj 评选最佳品牌 C++ 通过 1 MS 252 KB 1640 2026-05-15 15:46:02

Tests(2/2):


#include <iostream> #include <vector> #include <set> #include <string> #include <climits> using namespace std; int main() { int m, n; cin >> m >> n; vector<vector<int>> votes(n); for (int i = 0; i < n; ++i) { string s; cin >> s; vector<int> seq; for (char c : s) { seq.push_back(c - '0'); } votes[i] = seq; } set<int> active; for (int i = 1; i <= m; ++i) { active.insert(i); } while (active.size() > 1) { vector<int> count(m + 1, 0); for (const auto& seq : votes) { for (int x : seq) { if (x == 0) break; if (active.count(x)) { count[x]++; break; } } } int min_vote = INT_MAX; for (int b : active) { if (count[b] < min_vote) { min_vote = count[b]; } } bool all_min = true; for (int b : active) { if (count[b] != min_vote) { all_min = false; break; } } if (all_min) { cout << -min_vote << endl; return 0; } vector<int> to_remove; for (int b : active) { if (count[b] == min_vote) { to_remove.push_back(b); } } for (int b : to_remove) { active.erase(b); } } cout << *active.begin() << endl; return 0; }


测评信息: