結果

問題 No.11 カードマッチ
ユーザー monnumonnu
提出日時 2021-07-12 19:05:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 970 bytes
コンパイル時間 2,189 ms
コンパイル使用メモリ 168,104 KB
実行使用メモリ 10,956 KB
最終ジャッジ日時 2023-09-14 20:42:36
合計ジャッジ時間 3,391 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 6 ms
6,532 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 8 ms
10,956 KB
testcase_07 AC 4 ms
5,788 KB
testcase_08 AC 6 ms
7,108 KB
testcase_09 AC 9 ms
10,744 KB
testcase_10 AC 7 ms
9,608 KB
testcase_11 AC 7 ms
8,792 KB
testcase_12 AC 7 ms
8,996 KB
testcase_13 AC 6 ms
8,524 KB
testcase_14 AC 5 ms
6,024 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
//#define MOD 1000000007
#define MOD 998244353
//#define INF 1000000000
#define INF 1000000000000000000

int main(){
  int W,H,N;
  cin>>W>>H>>N;
  vector<int> S(N),K(N);
  for(int i=0;i<N;i++){
    cin>>S[i]>>K[i];
    S[i]--;K[i]--;
  }
  vector<int> cnt1(W,H),cnt2(H,W);
  for(int i=0;i<N;i++){
    cnt1[S[i]]--;
    cnt2[K[i]]--;
  }
  ll ans=0;
  vector<int> w,h;
  for(int i=0;i<W;i++){
    if(cnt1[i]<H){
      ans+=(ll)cnt1[i];
      w.push_back(i);
    }
  }
  for(int i=0;i<H;i++){
    if(cnt2[i]<W){
      ans+=(ll)cnt2[i];
      h.push_back(i);
    }
  }
  for(auto a:w){
    for(auto b:h){
      bool flag=true;
      for(int i=0;i<N;i++){
        if(S[i]==a&&K[i]==b){
          flag=false;
        }
      }
      if(flag==true){
        ans--;
      }
    }
  }
  cout<<ans<<endl;
}
0