Submission #00001
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include <bits/stdc++.h> using namespace std; int main() { map<pair<string, string>, int > cnt; int n, f; cin >> n >> f; for ( int i = 0; i < n; ++i) { int m; vector<string> items; cin >> m; for ( int j = 0; j < m; ++j) { string item; cin >> item; items.push_back(item); } sort(items.begin(), items.end()); for ( int j = 0; j < m; ++j) { for ( int k = j + 1; k < m; ++k) { pair<string, string> comb; comb = make_pair(items[j], items[k]); if (cnt.count(comb) == 0) { cnt[comb] = 1; } else { ++cnt[comb]; } } } } vector<pair<string, string> > ans; map<pair<string, string>, int >::iterator it = cnt.begin(); while (it != cnt.end()) { if (it->second >= f) { ans.push_back(it->first); } ++it; } cout << ans.size() << endl; for ( int i = 0; i < ans.size(); ++i) { cout << ans[i].first << " " << ans[i].second << endl; } } |
ステータス
項目 | データ |
---|---|
問題 | 0002 - 関連商品 |
ユーザー名 | 七代目清水天三郎丸 |
投稿日時 | 2017-10-24 16:01:42 |
言語 | C++11 |
状態 | Accepted |
得点 | 6 |
ソースコード長 | 1195 Byte |
最大実行時間 | 37 ms |
最大メモリ使用量 | 2484 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 6 / 6 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 30 ms | 480 KB |
1
|
in02.txt | AC | 19 ms | 448 KB |
1
|
in03.txt | AC | 21 ms | 676 KB |
1
|
in04.txt | AC | 32 ms | 2484 KB |
1
|
in05.txt | AC | 37 ms | 968 KB |
1
|
in06.txt | AC | 23 ms | 1816 KB |
1
|
in07.txt | AC | 21 ms | 1128 KB |
1
|
in08.txt | AC | 27 ms | 1060 KB |
1
|
in09.txt | AC | 20 ms | 1068 KB |
1
|
in10.txt | AC | 20 ms | 1212 KB |
1
|
in11.txt | AC | 19 ms | 1364 KB |
1
|
in12.txt | AC | 20 ms | 1372 KB |
1
|
in13.txt | AC | 21 ms | 1340 KB |
1
|
in14.txt | AC | 36 ms | 1304 KB |
1
|
in15.txt | AC | 15 ms | 1212 KB |
1
|
in16.txt | AC | 21 ms | 1284 KB |
1
|
in17.txt | AC | 16 ms | 1068 KB |
1
|
in18.txt | AC | 20 ms | 1088 KB |
1
|