QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#566913#9308. World CupKidding_MaCompile Error//C++17875b2024-09-16 03:12:312024-09-16 03:12:32

Judging History

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

  • [2024-09-16 03:12:32]
  • 评测
  • [2024-09-16 03:12:31]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;
using i64 = int64_t;
using ll = long long;
void solve() {
    int p = 0;
    vector<int> a(32);
    for (int i = 0; i < 32; i++) {
        cin >> a[i];
        p += a[i] < a[0];
    }

    auto b = a;
    sort(b.begin(), b.end());

    int p = lower_bound(b.begin(), b.end(), a[0]) - b.begin() + 1;
    if (p < 2) {
        cout << "32\n";
    } else if (p < 6) {
        cout << "16\n";
    } else if (p < 13) {
        cout << "8\n";
    } else if (p < 27) {
        cout << "4\n";
    } else if (p < 31) {
        cout << "2\n";
    } else {
        cout << "1\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

/*
4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3
*/

Details

answer.code: In function ‘void solve()’:
answer.code:17:9: error: redeclaration of ‘int p’
   17 |     int p = lower_bound(b.begin(), b.end(), a[0]) - b.begin() + 1;
      |         ^
answer.code:7:9: note: ‘int p’ previously declared here
    7 |     int p = 0;
      |         ^