結果

問題 No.3553 Good Quartet
コンテスト
ユーザー Iroha_3856
提出日時 2026-05-23 00:42:57
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 893 ms / 2,000 ms
コード長 828 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,453 ms
コンパイル使用メモリ 344,464 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2026-05-23 00:43:12
合計ジャッジ時間 13,072 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define all(x) (x).begin(), (x).end()

int main() {
    int N, Q; cin >> N >> Q;
    
    vector<map<int, int>> cnt(2);
    int ans = 0;
    
    vector<vector<int>> A = {
        {1, 5, 7, 11}, 
        {1, 11, 19, 29}
    };
    
    auto f = [&](int s, int d) -> void {
        for (int i : {0, 1}) {
            for (int b : A[i]) {
                if (s % b == 0) {
                    ans -= (cnt[i][s/b] == 4);
                    cnt[i][s/b] += d;
                    ans += (cnt[i][s/b] == 4);
                }
            }
        }
    };
    
    for (int i = 0; i < N; i++) {
        int s; cin >> s;
        f(s, 1);
    }
    
    while(Q--) {
        int q, s; cin >> q >> s;
        int t = (q == 1? 1 : -1);
        f(s, t);
        cout << ans << endl;
    }
}
0