Submission #877621

#TimeUsernameProblemLanguageResultExecution timeMemory
877621Ahmed_SolymanRadio (COCI22_radio)C++14
Compilation error
0 ms0 KiB
/* In the name of Allah made by: Ahmed_Solyman */ #include <bits/stdc++.h> #include <ext/rope> using namespace std; using namespace __gnu_cxx; #pragma GCC optimize("-Ofast") #pragma GCC optimize("-O1") //-------------------------------------------------------------// typedef long long ll; typedef unsigned long long ull; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define PI acos(-1) #define lb lower_bound #define ub upper_bound #define endl '\n' #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sum_to(n) (n*(n+1))/2 #define pb push_back #define pf push_front #define fil(arr,x) memset(arr,x,sizeof(arr)) const ll mod=1e9+7; int dx[8]={0,1,0,-1,1,1,-1,-1}; int dy[8]={1,0,-1,0,1,-1,-1,1}; //-------------------------------------------------------------// ll lcm(ll a,ll b) { return (max(a,b)/__gcd(a,b))*min(a,b); } void person_bool(bool x) { cout<<(x?"DA":"NE")<<endl; } const int N=1e6+5; vector<int>p[N]; struct segtree{ vector<ll>tree; int size; void init(int n){ size=n; tree.assign(n*4+5,0LL); } void set(int l,int r,int p,int i,int v){ if(l==r){ tree[p]=v; return; } int mid=(l+r)/2; if(i>mid)set(mid+1,r,p*2+1,i,v); else set(l,mid,p*2,i,v); tree[p]=max(tree[p*2],tree[p*2+1]); } void set(int i,int v){ set(1,size,1,i,v); } ll query(int l,int r,int p,int l_q,int r_q){ if(l>=l_q && r<=r_q){ return tree[p]; } if(r<l_q || l>r_q){ return 0; } int mid=(l+r)/2; return max(query(l,mid,p*2,l_q,r_q),query(mid+1,r,p*2+1,l_q,r_q)); } ll query(int l,int r){ return query(1,size,1,l,r); } }s; set<int>a[N],b[N],c[N]; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #ifndef ONLINE_JUDGE // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); #endif fast int n,q;cin>>n>>q; s.init(n); for(int i=2;i<=n;i++){ if(p[i].size()==0){ for(int j=i;j<=n;j+=i){ p[j].push_back(i); } } } vector<bool>state(n+5); vector<int>v(n+5); while(q--){ char t;cin>>t; if(t=='S'){ int x;cin>>x; state[x]=!state[x]; if(state[x]){ for(auto i:p[x]){ auto j=c[i].upper_bound(x); if(j!=c[i].begin()){ --j; v[x]=max(v[x],*j); s.set(x,v[x]); a[x].insert(*j); b[*j].insert(x); j++; } c[i].insert(x); if(j!=c[i].end()){ a[*j].insert(x); b[x].insert(*j); } } } else{ for(auto i:b[x]){ a[i].erase(x); if(!a[i].size()){ v[i]=0; s.set(i,v[i]); continue; } v[i]=*(--a[i].end()); s.set(i,v[i]); } for(auto i:p[x]){ c[i].erase(x); auto j=c[i].upper_bound(x); if(j!=c[i].end() && j!=c[i].begin()){ auto k=(--j); a[*j].insert(*k); b[*k].insert(*j); v[j]=*(--a[j].end()); s.set(j,v[j]); } } v[x]=0; b[x].clear(); a[x].clear(); s.set(x,v[x]); } } else{ int a,b;cin>>a>>b; person_bool(s.query(a,b)>=a); } } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:136:26: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::_Rb_tree_const_iterator<int>')
  136 |                         v[j]=*(--a[j].end());
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:5:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::_Rb_tree_const_iterator<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::_Rb_tree_const_iterator<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
Main.cpp:136:35: error: no match for 'operator[]' (operand types are 'std::set<int> [1000005]' and 'std::_Rb_tree_const_iterator<int>')
  136 |                         v[j]=*(--a[j].end());
      |                                   ^
Main.cpp:137:34: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::_Rb_tree_const_iterator<int>')
  137 |                         s.set(j,v[j]);
      |                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:5:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::_Rb_tree_const_iterator<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::_Rb_tree_const_iterator<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~