QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#792008#1086. Bank Security UnificationAme_Rain_chanCompile Error//C++14901b2024-11-28 22:51:302024-11-28 22:51:33

Judging History

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

  • [2024-11-28 22:51:33]
  • 评测
  • [2024-11-28 22:51:30]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+10;
int n;
ll a[N];
void debug(ll t){
    if(t >= 2) debug(t >> 1),cerr << char((t&1)+'0');
    else cerr << char((t&1)+'0');
}

int main(){
    //freopen("choice.in","r",stdin);
    //freopen("choice.out","w",stdout);

    scanf("%d",&n);
    for(int i=1;i <= n;i++){
        scanf("%lld",&a[i]);
    }
        ll ans=0;
        for(int t=0;t<1 << n;t++){
            ll lst=-1,res=0;
            for(int i=1;i <= n;i++){
                if(!((t >> (i-1))&1)) continue;
                if(lst<0) lst=a[i];
                else res += lst&a[i],lst=a[i];
            }
            ans=max(ans,res);
        }
        printf("%lld",ans);
    }
    return 0;
}

/*
g++ choice.cpp -o choice -std=c++14 -O2 -static -Wall -Wextra -fsanitize=undefined
./choice < choice.in > choice.out
*/

Details

answer.code:32:5: error: expected unqualified-id before ‘return’
   32 |     return 0;
      |     ^~~~~~
answer.code:33:1: error: expected declaration before ‘}’ token
   33 | }
      | ^
answer.code: In function ‘int main()’:
answer.code:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
answer.code:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~