QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#716728 | #9346. Binary Numbers | Xinyoucuo1dui# | WA | 17ms | 4936kb | C++14 | 1.3kb | 2024-11-06 15:54:26 | 2024-11-06 15:54:26 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define sz(a) ((int) (a).size())
#define ll long long
#define vi vectoe<int>
#define pb emplace_back
using namespace std;
#define VP vector<pair<int,int>>
const int N = 1 << 19, mod = 1e9 + 7;
int m, n;
int solve(int n, VP ps, int l) {
if(sz(ps) == 1) {
int sum = 0;
L(i, l, l + (1 << n) - 1) (sum += i) %= mod;
return sum;
}
int p = 0;
while(ps[p].second < l + (1 << (n - 1))) ++p;
if(ps[p].first == l + (1 << (n - 1))) {
VP ls, rs;
L(i, 0, p - 1) ls.pb(ps[i]);
L(i, p, sz(ps) - 1) rs.pb(ps[i]);
return (ll) solve(n - 1, ls, l) * solve(n - 1, rs, l + (1 << (n - 1))) % mod;
} else if(p == 0) {
VP rs;
L(i, p, sz(ps) - 1) rs.pb(ps[i]);
rs[0].first = l + (1 << (n - 1));
return solve(n - 1, rs, l + (1 << (n - 1)));
} else if(p == sz(ps) - 1) {
VP ls;
L(i, 0, p) ls.pb(ps[i]);
ls.back().second = l + (1 << (n - 1)) - 1;
return solve(n - 1, ls, l);
} else {
return 0;
}
}
void Main() {
cin >> n >> m;
vector<pair<int,int>>vp;
L(i, 1, m) {
int l, r;
cin >> l >> r;
vp.pb(l, r);
}
cout << solve(n, vp, 0) << '\n';
}
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t; cin >> t; while(t--) Main();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3476kb
input:
1 2 2 0 1 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: -100
Wrong Answer
time: 17ms
memory: 4936kb
input:
20 4 6 0 1 2 3 4 6 7 7 8 11 12 15 9 39 0 31 32 47 48 51 52 63 64 87 88 92 93 95 96 127 128 143 144 159 160 167 168 175 176 191 192 207 208 255 256 263 264 271 272 283 284 287 288 289 290 295 296 303 304 319 320 351 352 357 358 367 368 375 376 383 384 391 392 399 400 403 404 407 408 415 416 443 444 4...
output:
430920 87171513 728801388 496341250 754047900 5040 28188720 575181680 805603084 685858152 824671851 649673041 2268 147499198 1 478212216 706032500 516995748 28 252576307
result:
wrong answer 2nd lines differ - expected: '27651757', found: '87171513'