結果

問題 No.3553 Good Quartet
コンテスト
ユーザー askr58
提出日時 2026-05-22 23:45:15
言語 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
結果
WA  
実行時間 -
コード長 1,106 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,458 ms
コンパイル使用メモリ 340,016 KB
実行使用メモリ 14,336 KB
最終ジャッジ日時 2026-05-22 23:45:34
合計ジャッジ時間 10,457 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,q;
	cin>>n>>q;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	set<int> s;
	for(int i=0;i<n;i++)s.insert(a[i]);
	set<int> x,y;
	auto check=[&](int i)->void{
		if(s.count(11*i)&&s.count(19*i)&&s.count(29*i))y.insert(i);
		if(s.count(5*i)&&s.count(7*i)&&s.count(11*i))x.insert(i);
	};
	auto uncheck=[&](int i)->void{
		if(y.count(i)&&!(s.count(i)&&s.count(11*i)&&s.count(19*i)&&s.count(29*i)))y.erase(i);
		if(x.count(i)&&!(s.count(i)&&s.count(5*i)&&s.count(7*i)&&s.count(11*i)))x.erase(i);
		return;
	};
		
	for(int i:s){
		check(i);
	}
	while(q--){
		int t,p;
		cin>>t>>p;
		if(t==1){
			s.insert(p);
			if(p%5==0)check(p/5);
			if(p%7==0)check(p/7);
			if(p%11==0)check(p/11);
			if(p%19==0)check(p/19);
			if(p%29==0)check(p/29);
			check(p);
		}else{
			s.erase(p);
			uncheck(p);	
			if(p%5==0)uncheck(p/5);
			if(p%7==0)uncheck(p/7);
			if(p%11==0)uncheck(p/11);
			if(p%19==0)uncheck(p/19);
			if(p%29==0)uncheck(p/29);
		}
		cout<<x.size()+y.size()<<endl;
	}
}
0