結果

問題 No.1338 Giant Class
ユーザー ninoinui
提出日時 2021-01-16 09:26:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 2,627 ms
コンパイル使用メモリ 197,212 KB
最終ジャッジ日時 2025-01-17 21:19:46
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template <class A, class B> bool cmin(A& a, B b) { return a > b && (a = b, true); }
template <class A, class B> bool cmax(A& a, B b) { return a < b && (a = b, true); }

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  long H, W, Q;
  cin >> H >> W >> Q;
  long ans = H * W;
  map<long, long> MA;
  for (long i = 0; i < Q; i++) {
    long y, x;
    cin >> y >> x;
    if (MA.count(x)) {
      if (y >= MA[x]) {
        cout << ans << '\n';
      } else {
        ans += H - MA[x] + 1;
        ans -= H - y + 1;
        MA[x] = y;
        cout << ans << '\n';
      }
    } else {
      ans -= H - y + 1;
      MA[x] = y;
      cout << ans << '\n';
    }
  }
}
0