#include #include #include using namespace std;

int main() { int n, m, k; cin >> n >> m >> k; vector<vector> votes(n, vector(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> votes[i][j]; } }

vector<int> count(m, 0);
for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
        count[votes[j][i] - 1]++;
        if (count[votes[j][i] - 1] > n / 2) {
            cout << votes[j][i] << endl;
            cout << i << endl;
            return 0;
        }
    }
}

}

C++ 候选人投票获胜问题 - 算法实现与优化

原文地址: https://www.cveoy.top/t/topic/qg6L 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录