QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695284 | #9519. Build a Computer | paoxiaomo | AC ✓ | 0ms | 3756kb | C++20 | 3.2kb | 2024-10-31 19:42:08 | 2024-10-31 19:42:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b))
#define pb push_back
#define LNF 1e18
#define INF 0x7fffffff
#define int long long
#define lowbit(x) ((x) & (-x))
#define abs(x) llabs(x)
#define endl '\n'
#define Y() cout << "Yes" << endl
#define N() cout << "No" << endl
const db eps = 1e-9;
const int mod = 998244353;
const int MAXN = 2e5 + 5;
int l, r, cnt = 0, dp[1005][2][2];
vector<pair<int, int>> pth[1005], pt[1005];
int sol(int ws, int isl, int isr)
{
if (ws == -1)
return 1000;
if (dp[ws][isl][isr])
return dp[ws][isl][isr];
dp[ws][isl][isr] = ++cnt;
if (isl && isr)
{
if (l & (1 << ws))
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 1, 1), 1});
}
else if (r & (1 << ws))
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 0, 1), 1});
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 1, 0), 0});
}
else
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 1, 1), 0});
}
}
else if (isl)
{
if (l & (1 << ws))
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 1, 0), 1});
}
else
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 0, 0), 1});
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 1, 0), 0});
}
}
else if (isr)
{
if (r & (1 << ws))
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 0, 1), 1});
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 0, 0), 0});
}
else
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 0, 1), 0});
}
}
else
{
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 0, 0), 1});
pth[dp[ws][isl][isr]].push_back({sol(ws - 1, 0, 0), 0});
}
return dp[ws][isl][isr];
}
int is[1005];
map<int, int> mp;
void solve()
{
cin >> l >> r;
sol(21, 1, 1);
// cout << -1 << endl;
// cout << cnt << endl;
int now = 1;
for (int i = 1; i <= cnt; i++)
{
if (!is[i])
{
mp[i] = 1;
// cout << i << endl;
}
else
mp[i] = ++now;
// cout << i << endl;
for (auto [to, w] : pth[i])
{
is[to] |= w;
is[to] |= is[i];
// cout << to << " " << w << endl;
}
}
mp[1000] = ++now;
for (int i = 1; i <= cnt; i++)
{
for (auto [to, w] : pth[i])
{
if (mp[i] != mp[to])
pt[mp[i]].push_back({mp[to], w});
}
}
cout << now << endl;
for (int i = 1; i <= now; i++)
{
cout << pt[i].size() << " ";
for (auto [u, v] : pt[i])
cout << u << " " << v << " ";
cout << endl;
}
}
signed main()
{
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
5 7
output:
5 1 2 1 2 3 1 4 0 2 5 1 5 0 1 5 1 0
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
10 27
output:
12 2 2 1 9 1 2 3 1 7 0 1 4 0 2 5 1 6 0 2 12 1 12 0 2 12 1 12 0 2 8 1 8 0 2 6 1 6 0 2 8 1 10 0 1 11 1 2 12 1 12 0 0
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
5 13
output:
9 2 2 1 7 1 2 3 1 5 0 1 4 0 2 9 1 9 0 2 6 1 6 0 2 9 1 9 0 2 6 1 8 0 1 9 1 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
1 1000000
output:
39 20 2 1 38 1 37 1 35 1 36 1 30 1 31 1 32 1 33 1 34 1 27 1 28 1 29 1 21 1 22 1 23 1 24 1 25 1 26 1 39 1 2 3 1 38 0 2 4 1 37 0 2 5 1 35 0 1 6 0 2 7 1 30 0 1 8 0 1 9 0 1 10 0 1 11 0 2 12 1 27 0 1 13 0 1 14 0 2 15 1 21 0 1 16 0 1 17 0 1 18 0 1 19 0 1 20 0 1 39 0 2 22 1 22 0 2 23 1...
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 1
output:
2 1 2 1 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
7 9
output:
7 2 2 1 5 1 1 3 0 1 4 0 2 7 1 7 0 1 6 1 1 7 1 0
result:
ok ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
3 7
output:
6 2 2 1 5 1 2 3 1 4 0 2 6 1 6 0 2 6 1 6 0 1 6 1 0
result:
ok ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 5
output:
5 3 2 1 4 1 5 1 1 3 0 2 5 1 5 0 2 5 1 5 0 0
result:
ok ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 4
output:
5 3 2 1 4 1 5 1 1 3 0 1 5 0 2 5 1 5 0 0
result:
ok ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
8 9
output:
5 1 2 1 1 3 0 1 4 0 2 5 1 5 0 0
result:
ok ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
7 51
output:
13 4 2 1 8 1 9 1 11 1 2 3 1 8 0 1 4 0 1 5 0 2 6 1 7 0 2 13 1 13 0 2 13 1 13 0 2 9 1 9 0 2 10 1 10 0 2 7 1 7 0 1 12 1 1 13 1 0
result:
ok ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
51 79
output:
16 2 2 1 11 1 1 3 0 1 4 0 2 5 1 10 0 2 6 1 9 0 2 7 1 8 0 2 16 1 16 0 2 16 1 16 0 2 8 1 8 0 2 9 1 9 0 1 12 1 2 10 1 13 0 2 9 1 14 0 1 15 1 1 16 1 0
result:
ok ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
92 99
output:
14 1 2 1 2 3 1 9 0 1 4 0 1 5 0 1 6 0 2 7 1 8 0 2 14 1 14 0 2 14 1 14 0 1 10 1 1 11 1 1 12 1 2 8 1 13 0 2 14 1 14 0 0
result:
ok ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
27 36
output:
13 2 2 1 9 1 1 3 0 1 4 0 2 5 1 7 0 1 6 0 1 13 0 2 8 1 8 0 2 13 1 13 0 1 10 1 2 7 1 11 0 1 12 1 1 13 1 0
result:
ok ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
55 84
output:
17 2 2 1 12 1 1 3 0 2 4 1 10 0 1 5 0 2 6 1 8 0 1 7 0 1 17 0 2 9 1 9 0 2 17 1 17 0 2 11 1 11 0 2 8 1 8 0 1 13 1 2 11 1 14 0 1 15 1 1 16 1 1 17 1 0
result:
ok ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
297208 929600
output:
57 2 2 1 39 1 2 3 1 38 0 2 4 1 34 0 1 5 0 1 6 0 1 7 0 2 8 1 32 0 1 9 0 2 10 1 31 0 2 11 1 30 0 2 12 1 29 0 2 13 1 27 0 1 14 0 2 15 1 21 0 1 16 0 1 17 0 1 18 0 1 19 0 1 20 0 1 57 0 2 22 1 22 0 2 23 1 23 0 2 24 1 24 0 2 25 1 25 0 2 26 1 26 0 2 57 1 57 0 2 28 1 28 0 2 21 1 21...
result:
ok ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
45728 589156
output:
54 5 2 1 36 1 37 1 38 1 39 1 1 3 0 1 4 0 1 5 0 2 6 1 35 0 2 7 1 34 0 2 8 1 33 0 2 9 1 32 0 2 10 1 31 0 2 11 1 29 0 1 12 0 2 13 1 27 0 1 14 0 2 15 1 26 0 2 16 1 23 0 1 17 0 1 18 0 2 19 1 21 0 1 20 0 1 54 0 2 22 1 22 0 2 54 1 54 0 2 24 1 24 0 2 25 1 25 0 2 21 1 21 0 2 23 1 23 ...
result:
ok ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
129152 138000
output:
47 2 2 1 31 1 1 3 0 1 4 0 1 5 0 1 6 0 2 7 1 30 0 2 8 1 28 0 1 9 0 2 10 1 27 0 2 11 1 23 0 1 12 0 1 13 0 1 14 0 2 15 1 19 0 1 16 0 1 17 0 1 18 0 1 47 0 2 20 1 20 0 2 21 1 21 0 2 22 1 22 0 2 47 1 47 0 2 24 1 24 0 2 25 1 25 0 2 26 1 26 0 2 19 1 19 0 2 23 1 23 0 2 29 1 29 0 2...
result:
ok ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
245280 654141
output:
56 3 2 1 37 1 39 1 1 3 0 1 4 0 2 5 1 36 0 2 6 1 35 0 2 7 1 34 0 2 8 1 33 0 2 9 1 32 0 2 10 1 30 0 1 11 0 2 12 1 29 0 2 13 1 26 0 1 14 0 1 15 0 2 16 1 25 0 2 17 1 24 0 2 18 1 23 0 2 19 1 21 0 1 20 0 2 56 1 56 0 2 22 1 22 0 2 56 1 56 0 2 21 1 21 0 2 23 1 23 0 2 24 1 24 0 2 27 ...
result:
ok ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
202985 296000
output:
52 2 2 1 35 1 1 3 0 1 4 0 2 5 1 30 0 1 6 0 1 7 0 1 8 0 1 9 0 2 10 1 26 0 1 11 0 1 12 0 1 13 0 2 14 1 20 0 1 15 0 1 16 0 1 17 0 1 18 0 1 19 0 1 52 0 2 21 1 21 0 2 22 1 22 0 2 23 1 23 0 2 24 1 24 0 2 25 1 25 0 2 52 1 52 0 2 27 1 27 0 2 28 1 28 0 2 29 1 29 0 2 20 1 20 0 2 3...
result:
ok ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
438671 951305
output:
57 2 2 1 39 1 2 3 1 38 0 2 4 1 36 0 1 5 0 2 6 1 31 0 1 7 0 1 8 0 1 9 0 1 10 0 2 11 1 24 0 1 12 0 1 13 0 1 14 0 1 15 0 1 16 0 1 17 0 2 18 1 21 0 1 19 0 1 20 0 2 57 1 57 0 2 22 1 22 0 2 23 1 23 0 2 57 1 57 0 2 25 1 25 0 2 26 1 26 0 2 27 1 27 0 2 28 1 28 0 2 29 1 29 0 2 30 1...
result:
ok ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
425249 739633
output:
56 2 2 1 38 1 1 3 0 2 4 1 37 0 2 5 1 35 0 1 6 0 2 7 1 32 0 1 8 0 1 9 0 2 10 1 29 0 1 11 0 1 12 0 2 13 1 26 0 1 14 0 1 15 0 2 16 1 25 0 2 17 1 21 0 1 18 0 1 19 0 1 20 0 2 56 1 56 0 2 22 1 22 0 2 23 1 23 0 2 24 1 24 0 2 56 1 56 0 2 21 1 21 0 2 27 1 27 0 2 28 1 28 0 2 25 1 25...
result:
ok ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
551207 961718
output:
56 1 2 1 2 3 1 38 0 2 4 1 36 0 1 5 0 2 6 1 34 0 1 7 0 2 8 1 32 0 1 9 0 2 10 1 31 0 2 11 1 28 0 1 12 0 1 13 0 2 14 1 26 0 1 15 0 2 16 1 25 0 2 17 1 23 0 1 18 0 2 19 1 22 0 2 20 1 21 0 1 56 0 2 56 1 56 0 2 21 1 21 0 2 24 1 24 0 2 22 1 22 0 2 23 1 23 0 2 27 1 27 0 2 25 1 25 0 ...
result:
ok ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
114691 598186
output:
55 4 2 1 37 1 38 1 39 1 1 3 0 1 4 0 2 5 1 34 0 1 6 0 1 7 0 2 8 1 28 0 1 9 0 1 10 0 1 11 0 1 12 0 1 13 0 2 14 1 26 0 1 15 0 2 16 1 24 0 1 17 0 2 18 1 22 0 1 19 0 2 20 1 21 0 1 55 0 2 55 1 55 0 2 23 1 23 0 2 21 1 21 0 2 25 1 25 0 2 22 1 22 0 2 27 1 27 0 2 24 1 24 0 2 29 1 29...
result:
ok ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
234654 253129
output:
46 1 2 1 1 3 1 1 4 1 2 5 1 31 0 1 6 0 2 7 1 30 0 2 8 1 29 0 2 9 1 26 0 1 10 0 1 11 0 2 12 1 25 0 2 13 1 22 0 1 14 0 1 15 0 2 16 1 19 0 1 17 0 1 18 0 2 46 1 46 0 2 20 1 20 0 2 21 1 21 0 2 46 1 46 0 2 23 1 23 0 2 24 1 24 0 2 19 1 19 0 2 22 1 22 0 2 27 1 27 0 2 28 1 28 0 2 25...
result:
ok ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
554090 608599
output:
52 1 2 1 1 3 0 1 4 0 2 5 1 35 0 1 6 0 2 7 1 32 0 1 8 0 1 9 0 2 10 1 29 0 1 11 0 1 12 0 2 13 1 27 0 1 14 0 2 15 1 25 0 1 16 0 2 17 1 23 0 1 18 0 2 19 1 22 0 2 20 1 21 0 2 52 1 52 0 2 52 1 52 0 2 21 1 21 0 2 24 1 24 0 2 22 1 22 0 2 26 1 26 0 2 23 1 23 0 2 28 1 28 0 2 25 1 25...
result:
ok ok
Extra Test:
score: 0
Extra Test Passed