Submission #1093649

#TimeUsernameProblemLanguageResultExecution timeMemory
1093649ntdaccodeJoker (BOI20_joker)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define fori(i,a,b) for(int i=a;i<=b;i++) #define ll long long #define ii pair<int,int> #define fi first #define se second #define pb push_back using namespace std; const int mod=1e9+7; const int M=2e5+10; const int N=1e3+10; const int SIZE=448; int n,m,q; int x[M],y[M]; struct query { int l,r,idx; }Q[M]; int ret[M]; // dsu int id[M]; int dd[M],lz[M]; #define tp tuple<int,int,int,int> stack<tp> sk; stack<tp> ks; int finded(int u,int &v) { v^=lz[u]; return id[u] < 0 ? u : finded(id[u],v); } bool unioned(int tt ,int u,int v) { int pos=0,pos2=0; u=finded(u,pos); v=finded(v,pos2); if(u==v) { if(pos==pos2) return true; return false; } if(id[u]>id[v]) swap(u,v); if(tt!=0) { sk.push({tt,id[u],id[v],pos==pos2}); ks.push({tt,u,v,pos==pos2}); } if(pos==pos2) lz[v]^=1; id[u]+=id[v]; id[v]=u; return false; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "1" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n >> m >> q; fori(i,1,m) cin >> x[i] >> y[i]; fori(i,1,q) { cin >> Q[i].l >> Q[i].r ; Q[i].idx=i; } sort(Q+1,Q+q+1,[&] (const query a,const query b) { if(a.l/SIZE==b.l/SIZE) return a.r> b.r; return a.l<b.l; }); memset(id,-1,sizeof(id)); int r=m; bool ok=0; bool okk=0; fori(i,1,q) { // cout << Q[i].l << " " << Q[i].r << "ds\n"; if(Q[i-1].l/SIZE!=Q[i].l/SIZE) { while(!sk.empty()) { auto[tt,idu,idv,dog] = sk.top(); auto[tt2,u,v,cho] = ks.top(); sk.pop(); ks.pop(); lz[v]^=dog; id[u]=idu; id[v]=idv; } okk=0; fori(j,max(1ll,(Q[i-1].l/SIZE)*SIZE),min(m,(Q[i].l/SIZE)*SIZE-1)) if(unioned(0,x[j],y[j])) ok=1; //fori(i,1,n) cout << lz[i] << " " << id[i] << "\n"; //cout << Q[i].l << " " << Q[i].r << " " << max(1ll,(Q[i-1].l/SIZE)*SIZE) << " " <<min(m,(Q[i].l/SIZE)*SIZE-1) << "\n"; r=m; } //if(Q[i].l==9) cout << sk.size() << " "; while(Q[i].r<r&&r/SIZE!=Q[i].l/SIZE) { if(x[r]==y[r]) continue; if(unioned(1,x[r],y[r])) okk=1; //if(Q[i].l==7) cout << r << " "; r--; } //if(Q[i].l==2&&Q[i].r==6) cout << r << " "; if(ok||okk) ret[Q[i].idx]=1; else { int ook=0; //cout << (Q[i].l/SIZE)*SIZE << " " << r << "\n"; fori(j,max(1ll,(Q[i].l/SIZE)*SIZE),Q[i].l-1) { if(x[j]==y[j]) continue; if(unioned(2,x[j],y[j])) ook=1; } fori(j,Q[i].r+1,r) { if(x[j]==y[j]) continue; if(unioned(2,x[j],y[j])) ook=1; } while(!sk.empty()) { auto[tt,idu,idv,cho] = sk.top(); auto[tt2,u,v,dog] = ks.top(); if(tt!=2) break; sk.pop(); ks.pop(); lz[v]^=dog; id[u]=idu; id[v]=idv; } if(ook) ret[Q[i].idx]=1; } } fori(i,1,q) { if(ret[i]) cout << "YES\n"; else cout << "NO\n"; } }

Compilation message (stderr)

Joker.cpp: In function 'int32_t main()':
Joker.cpp:96:42: error: no matching function for call to 'max(long long int, int)'
   96 |       fori(j,max(1ll,(Q[i-1].l/SIZE)*SIZE),min(m,(Q[i].l/SIZE)*SIZE-1)) if(unioned(0,x[j],y[j])) ok=1;
      |                                          ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Joker.cpp:96:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   96 |       fori(j,max(1ll,(Q[i-1].l/SIZE)*SIZE),min(m,(Q[i].l/SIZE)*SIZE-1)) if(unioned(0,x[j],y[j])) ok=1;
      |                                          ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Joker.cpp:96:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   96 |       fori(j,max(1ll,(Q[i-1].l/SIZE)*SIZE),min(m,(Q[i].l/SIZE)*SIZE-1)) if(unioned(0,x[j],y[j])) ok=1;
      |                                          ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Joker.cpp:96:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   96 |       fori(j,max(1ll,(Q[i-1].l/SIZE)*SIZE),min(m,(Q[i].l/SIZE)*SIZE-1)) if(unioned(0,x[j],y[j])) ok=1;
      |                                          ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Joker.cpp:96:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   96 |       fori(j,max(1ll,(Q[i-1].l/SIZE)*SIZE),min(m,(Q[i].l/SIZE)*SIZE-1)) if(unioned(0,x[j],y[j])) ok=1;
      |                                          ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
Joker.cpp:115:40: error: no matching function for call to 'max(long long int, int)'
  115 |       fori(j,max(1ll,(Q[i].l/SIZE)*SIZE),Q[i].l-1)
      |                                        ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Joker.cpp:115:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  115 |       fori(j,max(1ll,(Q[i].l/SIZE)*SIZE),Q[i].l-1)
      |                                        ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Joker.cpp:115:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  115 |       fori(j,max(1ll,(Q[i].l/SIZE)*SIZE),Q[i].l-1)
      |                                        ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Joker.cpp:115:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  115 |       fori(j,max(1ll,(Q[i].l/SIZE)*SIZE),Q[i].l-1)
      |                                        ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Joker.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Joker.cpp:115:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  115 |       fori(j,max(1ll,(Q[i].l/SIZE)*SIZE),Q[i].l-1)
      |                                        ^
Joker.cpp:2:31: note: in definition of macro 'fori'
    2 | #define fori(i,a,b) for(int i=a;i<=b;i++)
      |                               ^
Joker.cpp:61:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:62:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~