1 条题解
-
0
【本题解由站长编写】
好芯片多于一半,且好芯片的测试结果一定正确:统计第 j 列里「判 j 为好」的票数,超过 n/2 说明投它好票的好芯片比坏芯片多,j 必是好芯片;否则是坏的。按编号升序输出。
代码(C++17)
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<int>> t(n, vector<int>(n)); for (auto &r : t) for (auto &x : r) cin >> x; bool first = true; for (int j = 0; j < n; j++) { int c = 0; for (int i = 0; i < n; i++) c += t[i][j]; if (c > n / 2) { if (!first) cout << ' '; cout << j + 1; first = false; } } cout << endl; return 0; }
- 1
信息
- ID
- 4084
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 3
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者