Submission #68809224
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
/////////////////// メイン ///////////////////
int main () {
//////////////////// 入力 ////////////////////
int n, m;
cin >> n >> m;
vector<string> s(n);
for (int i=0; i<n; i++) {
cin >> s.at(i);
}
//////////////// 出力変数定義 ////////////////
vector<int> result;
//////////////////// 処理 ////////////////////
// 各回どっちに得点が入るかを保管する文字列
string fewer(m,'*');
// 各回ごとに確認
for (int i=0; i<m; i++) {
// とりあえずカウンターを用意
int count0 = 0;
int count1 = 0;
// 全員分投票先を見て、人数を確認
for (int j=0; j<n; j++) {
if (s.at(j).at(i)=='0') count0++;
else count1++;
}
// どちらかが0人なら、そうじゃない側に得点(実は得点差が生じないので無視してもいい)
// 両方1人以上いるなら、少数派が得点
if (count0==0) fewer.at(i) = '1';
else if (count1==0) fewer.at(i) = '0';
else if (count0<count1) fewer.at(i) = '0';
else fewer.at(i) = '1';
}
// 各人の得点と、最大得点を計算
vector<int> scores(n,0);
int max_score = 0;
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
if (s.at(i).at(j)==fewer.at(j)) scores.at(i)++;
}
max_score = max (max_score,scores.at(i));
}
// 最大得点を取っている人をresultに詰め込む
for (int i=0; i<n; i++) {
if (scores.at(i)==max_score) result.emplace_back(i+1);
}
//////////////////// 出力 ////////////////////
// 空白区切りで出力
for (size_t i=0; i<result.size(); i++) {
cout << result.at(i);
if (i!=result.size()-1) {
cout << " ";
}
}
cout << endl;
//////////////////// 終了 ////////////////////
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Most Minority |
| User | wightou |
| Language | C++ 23 (gcc 12.2) |
| Score | 200 |
| Code Size | 1928 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3744 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample_01.txt | AC | 1 ms | 3532 KiB |
| sample_02.txt | AC | 1 ms | 3464 KiB |
| sample_03.txt | AC | 1 ms | 3484 KiB |
| test_01.txt | AC | 1 ms | 3576 KiB |
| test_02.txt | AC | 1 ms | 3588 KiB |
| test_03.txt | AC | 1 ms | 3528 KiB |
| test_04.txt | AC | 1 ms | 3728 KiB |
| test_05.txt | AC | 1 ms | 3584 KiB |
| test_06.txt | AC | 1 ms | 3604 KiB |
| test_07.txt | AC | 1 ms | 3580 KiB |
| test_08.txt | AC | 1 ms | 3492 KiB |
| test_09.txt | AC | 1 ms | 3472 KiB |
| test_10.txt | AC | 1 ms | 3536 KiB |
| test_11.txt | AC | 1 ms | 3476 KiB |
| test_12.txt | AC | 1 ms | 3528 KiB |
| test_13.txt | AC | 1 ms | 3592 KiB |
| test_14.txt | AC | 1 ms | 3740 KiB |
| test_15.txt | AC | 1 ms | 3496 KiB |
| test_16.txt | AC | 1 ms | 3584 KiB |
| test_17.txt | AC | 1 ms | 3592 KiB |
| test_18.txt | AC | 1 ms | 3484 KiB |
| test_19.txt | AC | 1 ms | 3604 KiB |
| test_20.txt | AC | 1 ms | 3744 KiB |
| test_21.txt | AC | 1 ms | 3664 KiB |
| test_22.txt | AC | 1 ms | 3544 KiB |
| test_23.txt | AC | 1 ms | 3536 KiB |
| test_24.txt | AC | 1 ms | 3604 KiB |