답안 #1003437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003437 2024-06-20T10:38:26 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> tm[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 (tm[v].size()>0) tm[v].clear();
		else 
		{
			for (auto x:prime)
			{
				if (u%x==0) tm[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]);

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

	for (auto x:tm[2*v+2])
	{
		tm[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:tm[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()
{
    //freopen ("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 'void status(ll, ll, ll, ll)':
Main.cpp:64:7: error: reference to 'tm' is ambiguous
   64 |   if (tm[v].size()>0) tm[v].clear();
      |       ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:64:23: error: reference to 'tm' is ambiguous
   64 |   if (tm[v].size()>0) tm[v].clear();
      |                       ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:69:17: error: reference to 'tm' is ambiguous
   69 |     if (u%x==0) tm[v].insert(x);
      |                 ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:81:2: error: reference to 'tm' is ambiguous
   81 |  tm[v].clear();
      |  ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:82:14: error: reference to 'tm' is ambiguous
   82 |  for (auto x:tm[2*v+1])
      |              ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:84:7: error: reference to 'tm' is ambiguous
   84 |   if (tm[2*v+2].count(x)) ts[v]=1;
      |       ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:85:3: error: reference to 'tm' is ambiguous
   85 |   tm[v].insert(x);
      |   ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:88:14: error: reference to 'tm' is ambiguous
   88 |  for (auto x:tm[2*v+2])
      |              ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp:90:3: error: reference to 'tm' is ambiguous
   90 |   tm[v].insert(x);
      |   ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~
Main.cpp: In function 'void query(ll, ll, ll, ll, ll)':
Main.cpp:101:15: error: reference to 'tm' is ambiguous
  101 |   for (auto x:tm[v])
      |               ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
Main.cpp:13:9: note:                 'std::set<int> tm [4000028]'
   13 | set<ll> tm[4*DIM];
      |         ^~