QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499581#6730. Coolbits1DemonS1WA 169ms5200kbC++201.1kb2024-07-31 15:55:112024-07-31 15:55:13

Judging History

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

  • [2024-07-31 15:55:13]
  • 评测
  • 测评结果:WA
  • 用时:169ms
  • 内存:5200kb
  • [2024-07-31 15:55:11]
  • 提交

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;
}
int cmpp[20];
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++;
        }
        cmpp[1] = 1;
        for (int i = 2; i <= 20; ++i) cmpp[i] = cmpp[i - 1] * 2;
        for (int i = 2; i <= n; ++i) {
            int mi = G[i].first & cmpp[kase];
            int size = G[i].second - G[i].first;
            if (mi + size >= m) continue;
            m = mi + size;
            if (m <= cmpp[kase - 1]) kase--;
        }
        cout << m << endl;
    }
    return 0;
}

详细

Test #1:

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

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: 169ms
memory: 5200kb

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:

12899751
2886411
67803110
408149
8430298
885460
12770845
2282552
4674560
29425165
54805824
2440095
1995356
11153457
8337581
8196885
4834128
4034910
160357
8319257
4605435
837643
3540961
19193421
20604384
14851877
15251436
14823837
23333962
9425927
2729231
28231194
39667058
1449106
41720666
50182254
...

result:

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