记录详情

Time Exceeded

/in/foo.cc: In function 'int main()':
/in/foo.cc:21:44: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
         while ((nums[i] >> highestBit) & 1 == 0) {
                                          ~~^~~~
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 456.0 KiB
#2 Wrong Answer 3ms 448.0 KiB
#3 Time Exceeded ≥1000ms ≥796.0 KiB
#4 Time Exceeded ≥1001ms ≥720.0 KiB
#5 Time Exceeded ≥1000ms ≥740.0 KiB
#6 Time Exceeded ≥1000ms ≥760.0 KiB
#7 Time Exceeded ≥1001ms ≥772.0 KiB
#8 Time Exceeded ≥1002ms ≥752.0 KiB
#9 Time Exceeded ≥1003ms ≥772.0 KiB
#10 Time Exceeded ≥1002ms ≥716.0 KiB

代码

#include <iostream>
#include <vector>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<int> nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }

    long long result = 0;
    for (int i = 0; i < n; ++i) {
        int highestBit = 0;
        while ((nums[i] >> highestBit) & 1 == 0) {
            ++highestBit;
        }
        for (int j = i + 1; j < n; ++j) {
            if (((nums[j] >> highestBit) & 1) && (nums[i] & nums[j]) > (nums[i] ^ nums[j])) {
                ++result;
            }
        }
    }

    cout << result << endl;
    return 0;
}

信息

递交者
类型
递交
题目
P1002 统计
语言
C++
递交时间
2024-09-10 19:30:29
评测时间
2024-09-10 19:30:29
评测机
分数
0
总耗时
≥8020ms
峰值内存
≥796.0 KiB