QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#219317 | #6730. Coolbits | Yangmf | WA | 211ms | 6596kb | C++17 | 1.7kb | 2023-10-19 11:59:20 | 2023-10-19 11:59:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
#define M(x) \
{ \
x %= mod; \
if (x < 0) \
x += mod; \
}
#define error \
{ \
cout << "No\n"; \
return; \
}
#define all(x) (x.begin(), x.end())
const int N = 1e6 + 10;
int a[N];
int n, m;
int l[N], r[N];
bool tui[N];
void solve()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> l[i] >> r[i];
tui[i] = 0;
}
int ans = 0;
int msk = 0;
for (int i = 29; i >= 0; i--)
{
msk += 1 << i;
int f = 1;
for (int j = 1; j <= n; j++)
{
if (f == 0)
break;
if (!(r[j] & (1 << i)))
f = 0;
}
if (f == 1)
{
ans += 1 << i;
}
for (int j = 1; j <= n; j++)
{
if ((msk & r[j]) > ans && ((r[j] & msk) - 1 >= l[j]) && !tui[j])
{
r[j] = (r[j] & msk) - 1;
tui[j] = 1;
} else if((msk&r[j])>ans&&!tui[j]) {
r[j]=r[j]-(1<<i);
}
}
}
cout << ans << "\n";
}
void print(int x)
{
for (int i = 29; i >= 0; i--)
{
cout << ((x >> i) & 1);
}
cout << "\n";
}
signed main()
{
// freopen("D://Desktop//VSCODE//input.txt", "r", stdin);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
// 29882460 33554431
// print(29882460);
// print(93281727);
while (t--)
{
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5720kb
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: 211ms
memory: 6596kb
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:
0 0 605885728 0 0 0 0 0 0 0 0 0 0 1050116 0 0 173845856 0 0 135004194 0 0 0 0 276824064 0 327716 0 0 0 0 0 0 0 0 248157637 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41959424 0 0 113770496 0 0 651037082 0 0 4196418 0 0 0 0 2097664 0 0 21250131 0 850937702 135168 612072952 0 0 0 400892223 0 0 0 0 0 34177536...
result:
wrong answer 1st numbers differ - expected: '29882460', found: '0'