結果

問題 No.11 カードマッチ
ユーザー lioolioo
提出日時 2021-04-13 23:02:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 618 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 63,832 KB
実行使用メモリ 5,572 KB
最終ジャッジ日時 2023-09-12 13:41:14
合計ジャッジ時間 2,016 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,296 KB
testcase_01 AC 3 ms
5,272 KB
testcase_02 AC 3 ms
5,268 KB
testcase_03 AC 3 ms
5,572 KB
testcase_04 AC 3 ms
5,300 KB
testcase_05 AC 3 ms
5,272 KB
testcase_06 AC 4 ms
5,264 KB
testcase_07 AC 3 ms
5,368 KB
testcase_08 AC 3 ms
5,540 KB
testcase_09 AC 4 ms
5,348 KB
testcase_10 AC 4 ms
5,316 KB
testcase_11 AC 4 ms
5,300 KB
testcase_12 AC 4 ms
5,280 KB
testcase_13 AC 4 ms
5,448 KB
testcase_14 AC 3 ms
5,296 KB
testcase_15 AC 3 ms
5,260 KB
testcase_16 AC 3 ms
5,292 KB
testcase_17 AC 3 ms
5,264 KB
testcase_18 AC 3 ms
5,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int main(){
    bool existw[1000001]={};
    bool existh[1000001]={};
    int W;
    int H;
    int N;

    cin>>W>>H>>N;
    for(int i=0;i<N;i++){
        int s,k;
        cin>>s>>k;
        existw[s]=existh[k]=true;
    }

    long long int wcount=0;
    long long int hcount=0;
    for(int i=1;i<=W;i++){
        if (existw[i]){
            wcount++;
        }
    }
    for(int j=1;j<=H;j++){
        if (existh[j]){
            hcount++;
        }
    }

    long long int ans;
    ans = wcount*H+hcount*W;
    ans -= wcount*hcount;
    ans -= N;

    cout<<ans<<endl;
}
0