QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706978#8332. Two in OnewangshengzheCompile Error//C++141.7kb2024-11-03 14:12:372024-11-03 14:12:38

Judging History

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

  • [2024-11-03 14:12:38]
  • 评测
  • [2024-11-03 14:12:37]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<unordered_map>
#include<stack>
using namespace std;
//#define int long long
//#define scanf scanf_s
typedef pair<int, int> PII;
const int mod = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double ef = 1e-12;

#define rep(i,a, b) for(int i = a;i<=b;i++)
#define pre(i,a, b) for(int i = a;i>=b;i--)


using ll = long long;
const int N = 200005;
#define pb push_back
#define sc(x) scanf("%d",&x)

const int mod = 1e9 + 9;
int hz[35];
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;
    rep(i, 1, n) {
        int x; sc(x); cnt[x]++;
    }
    int mx = 0, cmx = 0;
    sort(cnt + 1, cnt + n + 1);
    mx = cnt[n];
    cmx = cnt[n - 1];
    if (!cmx) {
        printf("%d\n", mx);
    }
    else
        printf("%d\n", get(mx, cmx));

}


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:18:17: warning: overflow in conversion from ‘long int’ to ‘int’ changes value from ‘4557430888798830399’ to ‘1061109567’ [-Woverflow]
   18 | const int INF = 0x3f3f3f3f3f3f3f3f;
      |                 ^~~~~~~~~~~~~~~~~~
answer.code:30:11: error: redefinition of ‘const int mod’
   30 | const int mod = 1e9 + 9;
      |           ^~~
answer.code:17:11: note: ‘const int mod’ previously defined here
   17 | const int mod = 1000000007;
      |           ^~~
answer.code: In function ‘void solve()’:
answer.code:28:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 | #define sc(x) scanf("%d",&x)
      |               ~~~~~^~~~~~~~~
answer.code:60:5: note: in expansion of macro ‘sc’
   60 |     sc(n);
      |     ^~
answer.code:28:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 | #define sc(x) scanf("%d",&x)
      |               ~~~~~^~~~~~~~~
answer.code:63:16: note: in expansion of macro ‘sc’
   63 |         int x; sc(x); cnt[x]++;
      |                ^~