QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706823#8332. Two in OneAnnelieseCompile Error//C++141.7kb2024-11-03 13:34:502024-11-03 13:34:51

Judging History

你现在查看的是最新测评结果

  • [2024-11-03 13:34:51]
  • 评测
  • [2024-11-03 13:34:50]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
using ll = long long;
const int N = 100005;
#define rep(i,a ,b )  for(int i = a ;i<=b;i++)
#define pre(i,a ,b )  for(int i = a ;i>=b;i--)
#define pb push_back
#define sc(x) scanf("%d",&x)

const int mod=1e9+9;
ll hz[25];
int get(int x,int y){
	int res=0;
	pre(i,20,0){
		int u=0,v=0;
		if((x&(1<<i))){
			u=1;
		}
		if((y&(1<<i))){
			v=1;
		}
		if(!u&&!v)continue;
		//cout<<i<<" "<<u<<" "<<v<<endl;
		if(u==v){
			res|=hz[i];
			return res;
		}
		else{
			res|=(1<<i);
		}
	}
	return res;
}
int cnt[N];
void solve() {
	int n;
	sc(n);
	rep(i,1,n)cnt[i]=0;vector<int>p[25];
	rep(i,1,n){
		int x;sc(x);cnt[x]++;
	}
	rep(i,1,n){
		int nw=0;if(!cnt[i])continue;
		int x=cnt[i];
		rep(j,0,20){
			if(((1<<j)&x)){
				nw=j;
			}
		}
		p[nw].pb(x);
	}
	ll res=0;
	pre(i,20,0){
		if(p[i].size()==0)continue;
		if(p[i].size()>1){
			res=hz[i];
			break;
		}
		else{
			int fg=0,ne=0;
		//	cout<<p[1].size()<<" "<<i<<endl;
			pre(j,i-1,0){
				if(p[j].size()>0){
					fg=1;ne=j;break;
				}
			}
			//cout<<ne<<" "<<p[ne].size()<<" "<<fg<<endl;
			if(!fg){//不存在其他数 
				res=p[i][0];
				break;
				//printf("%lld\n",p[i][0]);
			}
			else{
				if(p[ne].size())
				rep(j,0,p[ne].size()-1){
				//	cout<<p[ne][j]<<" "<<p[i][0]<<endl;
					res=max(res,get(p[i][0],p[ne][j]));
				}
			}
			break;
		}
	}
	printf("%lld\n",res);
}


int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    hz[0]=1;
	rep(i,1,20){
		hz[i]=(hz[i-1]|(1<<i));
	}
    int t = 1;
    cin >> t ;

    while (t--) {
        solve();
    }

    return 0;


}

Details

answer.code: In function ‘void solve()’:
answer.code:79:48: error: no matching function for call to ‘max(ll&, int)’
   79 |                                         res=max(res,get(p[i][0],p[ne][j]));
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:79:48: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   79 |                                         res=max(res,get(p[i][0],p[ne][j]));
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:79:48: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   79 |                                         res=max(res,get(p[i][0],p[ne][j]));
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:79:48: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   79 |                                         res=max(res,get(p[i][0],p[ne][j]));
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:79:48: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   79 |                                         res=max(res,get(p[i][0],p[ne][j]));
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | #define sc(x) scanf("%d",&x)
      |               ~~~~~^~~~~~~~~
answer.code:39:9: note: in expansion of macro ‘sc’
   39 |         sc(n);
      |         ^~
answer.code:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | #define sc(x) scanf("%d",&x)
      |               ~~~~~^~~~~~~~~
answer.code:42:23: note: in expansion of macro ‘sc’
   42 |                 int x;sc(x);cnt[x]++;
      |                       ^~