제출 #201951

#제출 시각아이디문제언어결과실행 시간메모리
201951awlintqaaZamjene (COCI16_zamjene)C++14
컴파일 에러
0 ms0 KiB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #include <bits/stdc++.h> using namespace std; #define sqr 340 #define mid (l+r)/2 #define pb push_back #define ppb pop_back #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ins insert #define era erase #define C continue #define mem(dp,i) memset(dp,i,sizeof(dp)) #define mset multiset typedef long long ll; typedef short int si; typedef long double ld; typedef pair<int,int> pi; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; const ll mod=1e9+7; const ll inf=1e18*4; const ld pai=acos(-1); ll n,q; ll a[1000009],b[1000009]; ll p[1000009]; ll hasha[1000009],hashb[1000009],sz[1000009]; ll loser,ans; map<ll,ll>mp; ll H=1234577; ll po[1000009]; void show(){ cout<<loser<<" "<<ans<<endl; for(int i=0;i<n;i++)cout<<hasha[i]<<" "<<hashb[i]<<endl; cout<<"--------------"<<endl; } ll get(ll node){ if(p[node]==node)return node; return p[node]=get(p[node]); } void fill(){ po[0]=1; for(ll i=1;i<=1e6;i++){ po[i]=po[i-1]*H; po[i]%=mod; } } ll HASH(ll x){return po[x];} void in(ll node){ mp[hasha[node]-hashb[node]]+=sz[get(node)]; mp[0]=0; ans+=mp[-hasha[node]+hashb[node]]*sz[get(node)]; loser+=(hasha[node]!=hashb[node]); } void out(ll node){ mp[hasha[node]-hashb[node]]-=sz[get(node)]; mp[0]=0; ans-=mp[-hasha[node]+hashb[node]]*sz[get(node)]; loser-=(hasha[node]!=hashb[node]); } void add(ll node,ll x){ hasha[node]+=HASH(a[x]); hasha[node]%=mod; } void remove(ll node,ll x){ hasha[node]-=HASH(a[x]); hasha[node]+=mod; hasha[node]%=mod; } void xxx(int x,int y){ swap(a[x],a[y]); } int main(){ cin>>n>>q; for(int i=0;i<n;i++)cin>>a[i],b[i]=a[i]; sort(b,b+n); fill(); for(int i=0;i<n;i++){ p[i]=i; sz[i]=1; hasha[i]=HASH(a[i]); hashb[i]=HASH(b[i]); in(i); } //show(); while(q--){ int t;cin>>t; if(t==1){ ll a,b; cin>>a>>b; a--,b--; if(get(a)==get(b))C; out(get(a)); out(get(b)); add(get(a),b); remove(get(a),a); add(get(b),a); remove(get(b),b); in(get(a)); in(get(b)); xxx(a,b); } if(t==2){ ll a,b; cin>>a>>b; a--,b--; merge(a,b); } if(t==3){ if(loser)cout<<"NE"<<endl; else cout<<"DA"<<endl; } if(t==4){ cout<<ans<<endl; } //show(); } }

컴파일 시 표준 에러 (stderr) 메시지

zamjene.cpp: In function 'int main()':
zamjene.cpp:112:34: error: no matching function for call to 'merge(ll&, ll&)'
                         merge(a,b);
                                  ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from zamjene.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4918:5: note: candidate: template<class _IIter1, class _IIter2, class _OIter> _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter)
     merge(_InputIterator1 __first1, _InputIterator1 __last1,
     ^~~~~
/usr/include/c++/7/bits/stl_algo.h:4918:5: note:   template argument deduction/substitution failed:
zamjene.cpp:112:34: note:   candidate expects 5 arguments, 2 provided
                         merge(a,b);
                                  ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from zamjene.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4968:5: note: candidate: template<class _IIter1, class _IIter2, class _OIter, class _Compare> _OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare)
     merge(_InputIterator1 __first1, _InputIterator1 __last1,
     ^~~~~
/usr/include/c++/7/bits/stl_algo.h:4968:5: note:   template argument deduction/substitution failed:
zamjene.cpp:112:34: note:   candidate expects 6 arguments, 2 provided
                         merge(a,b);
                                  ^