結果

問題 No.11 カードマッチ
ユーザー CleyLCleyL
提出日時 2020-02-29 23:49:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 965 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 88,848 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-03 23:16:51
合計ジャッジ時間 2,122 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long h,w,n;cin>>h>>w>>n;
    map<long long,long long> M;
    map<long long,long long> V;
    set<long long> Ms;
    set<long long> Vs;
    vector<pair<long long,long long> > A(n);
    for(int i = 0; n > i; i++){
        long long a,b;cin>>a>>b;
        M[a]++;
        V[b]++;
        Ms.insert(a);
        Vs.insert(b);
        A[i].first = a;
        A[i].second = b;
    }
    long long ans = 0;
    for(auto x: M){
        ans += w-x.second;
    }
    for(auto x: V){
        ans += h-x.second;
    }
    for(auto x: Ms){
        for(auto y: Vs){
            bool t = true;
            for(int i = 0; n > i; i++){
                if(x == A[i].first && y == A[i].second){
                    t = false;
                    break;
                }
            }
            ans -= t;
        }
    }
    cout << ans << endl;
    
}
0