답안 #1003439

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003439 2024-06-20T10:40:20 Z ulianamalanyak Radio (COCI22_radio) C++14
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"

using namespace std;

#define endl '\n'
#define INF 1000000000000

typedef int ll;

const int DIM=1e6+7;

ll n,q,multiple;
set<ll> tmm[4*DIM];
int ts[4*DIM];
int a[DIM];
set<ll> prime,s;
bool fl;

ll gcd(ll p1, ll p2)
{
	for (auto x:prime)
	{
		if (p1%x==0&&p2%x==0) return x;
	}
	return 1;
}

void euclid()
{
	for (int i=2;i<=1000000;i++)
	{
		if (a[i]==0)
		{
			prime.insert(i);

			for (int j=i;j<=1000000;j+=i)
			{
				a[j]=1;
			}
		}
	}
}

void init(ll v, ll tl, ll tr)
{
	if (tl==tr)
	{
		ts[v]=0;
		return;
	}

	ll mid=(tl+tr)/2;
	init(2*v+1,tl,mid);
	init(2*v+2,mid+1,tr);
	ts[v]=0;
}

void status(ll v, ll tl, ll tr, ll u)
{
	if (u<tl||u>tr) return;

	if (tl==tr)
	{
		if (tmm[v].size()>0) tmm[v].clear();
		else 
		{
			for (auto x:prime)
			{
				if (u%x==0) tmm[v].insert(x);
			}
		}
		return;
	}

	ll mid=(tl+tr)/2;
	status(2*v+1,tl,mid,u);
	status(2*v+2,mid+1,tr,u);

	ts[v]=max(ts[2*v+1],ts[2*v+2]);

	tmm[v].clear();
	for (auto x:tmm[2*v+1])
	{
		if (tmm[2*v+2].count(x)) ts[v]=1;
		tmm[v].insert(x);
	}

	for (auto x:tmm[2*v+2])
	{
		tmm[v].insert(x);
	}
}

void query(ll v, ll tl, ll tr, ll l, ll r)
{
	if (r<tl||l>tr) return;

	if (l<=tl&&tr<=r) 
	{
		if (ts[v]) fl=1;
		for (auto x:tmm[v])
		{
			if (s.count(x)) fl=1;
			s.insert(x);
		}
		return;
	}
	
	ll mid=(tl+tr)/2;
	query(2*v+1,tl,mid,l,r);
	query(2*v+2,mid+1,tr,l,r);
	return;
}

int main()
{
    f//reopen ("input.txt","r",stdin);
    //freopen ("output.txt","w",stdout);
    
    cin >> n >> q;

	euclid();

	init(0,1,n);

	while(q--)
	{
		char c;

		cin >> c;

		if (c=='S')
		{
			ll x;
			cin >> x;
			status(0,1,n,x);
		}
		else 
		{
			ll l,r;
			cin >> l >> r;
			s.clear();
			fl=0;
			query(0,1,n,l,r);

			if (fl) cout << "DA" << endl;
			else cout << "NE" << endl;
		}
	}
  
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:117:5: error: 'f' was not declared in this scope; did you mean 'fl'?
  117 |     f//reopen ("input.txt","r",stdin);
      |     ^
      |     fl