結果

問題 No.11 カードマッチ
ユーザー nemunemunemunemu
提出日時 2024-01-13 19:12:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 740 bytes
コンパイル時間 1,084 ms
コンパイル使用メモリ 88,236 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-13 19:12:52
合計ジャッジ時間 2,298 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   22 |         auto [s, k] = v[i];
      |              ^
main.cpp:27:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   27 |     for (auto [key, st] : add_m) {
      |               ^
main.cpp:30:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   30 |     for (auto [key, st] : add_n) {
      |               ^

ソースコード

diff #

// No.11 カードマッチ
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    vector<pair<int, int>> v;
    for (int i = 0; i < N; ++i) {
        int S, K;
        cin >> S >> K;
        --S, --K;
        v.emplace_back(S, K);
    }
    map<int, set<int>> add_m;
    map<int, set<int>> add_n;
    for (int i = 0; i < N; ++i) {
        auto [s, k] = v[i];
        add_m[s].insert(k);
        add_n[k].insert(s);
    }
    ll res = 0;
    for (auto [key, st] : add_m) {
        res += H - st.size();
    }
    for (auto [key, st] : add_n) {
        res += W - max(st.size(), add_m.size());
    }
    cout << res << endl;
}
0