QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499522#6730. Coolbits1DemonS1WA 179ms5596kbC++201.0kb2024-07-31 15:14:462024-07-31 15:14:52

Judging History

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

  • [2024-07-31 15:14:52]
  • 评测
  • 测评结果:WA
  • 用时:179ms
  • 内存:5596kb
  • [2024-07-31 15:14:46]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define ll long long
#define PII std::pair<int,int>
using namespace std;
const int maxn = 1e5 + 5;
bool cmp(PII p1, PII p2) {
    if (p1.second == p2.second) return p1.first < p2.second;
    return p1.second < p2.second;
}
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int T; cin >> T;
    while (T--) {
        int n; cin >> n;
        vector<PII> G(n + 1);
        for (int i = 1; i <= n; ++i) {
            cin>>G[i].first>>G[i].second;
        }
        sort(G.begin() + 1, G.end(), cmp);
        int m = G[1].second;
        int kase = 0, temp = m;
        while (temp) {
            temp >>= 1;
            kase++;
        }
        int cmpp = pow(2, kase) - 1;
        for (int i = 2; i <= n; ++i) {
            int mi = G[i].first & cmpp;
            int size = G[i].second - G[i].first + 1;
            if (size >= m || mi + size >= m) continue;
            m = mi + size;
        }
        cout << m << endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3888kb

input:

2
3
0 8
2 6
3 9
1
1 100

output:

6
100

result:

ok 2 number(s): "6 100"

Test #2:

score: -100
Wrong Answer
time: 179ms
memory: 5596kb

input:

1117
74
234256176 451122435
614716780 701954053
31102604 284818525
528763990 809400397
40637446 612671528
329403504 936190213
112402633 729525189
248142852 481053286
30877745 700834811
529884578 749041634
146522084 758550567
934650972 996096650
538751855 856147351
170918541 975066425
253153230 35361...

output:

42650889
10439884
605885728
99468425
63196708
11692711
16776651
126668028
68319701
252734495
144137157
42855333
56772758
43488869
44009819
32268397
173845857
33376286
27546346
135007650
59452365
4291991
127176436
70543108
383607069
37817927
43510328
67560241
113933076
76801657
44267230
100671965
600...

result:

wrong answer 1st numbers differ - expected: '29882460', found: '42650889'