QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628275 | #9346. Binary Numbers | liuyz11 | WA | 68ms | 78128kb | C++20 | 1.8kb | 2024-10-10 19:24:56 | 2024-10-10 19:25:01 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(x, l, r) for(int x = l; x <= r; x++)
#define repd(x, r, l) for(int x = r; x >= l; x--)
#define clr(x, y) memset(x, y, sizeof(x))
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;
const int MAXM = 25;
const int mod = 1e9 + 7;
int sum[MAXN][MAXM][MAXM], l[MAXN], r[MAXN];
int judge(int x, int y){
int res = x ^ y;
// printf("%d %d %d\n", x, y, res);
repd(i, 20, 0){
if((1 << i) & res) return i + 1;
}
return 0;
}
int main(){
// rep(i, 1, 100){
// rep(j, i, 100) printf("%d ", judge(i, j));
// puts("");
// }
int t;
scanf("%d", &t);
while(t--){
int n, m;
scanf("%d%d", &m, &n);
rep(i, 1, n){
rep(j, 0, m + 1)
rep(k, 0, m + 1) sum[i][j][k] = 0;
}
rep(i, 1, n){
scanf("%d%d", &l[i], &r[i]);
}
rep(i, l[1], r[1]){
int w = judge(i, l[2]), v = judge(i, r[1]);
sum[1][w][v] = (sum[1][w][v] + i) % mod;
// printf("%d 1 : %d %d %d\n", i, w, v, sum[1][w][v]);
}
l[n + 1] = 1 << m;
rep(i, 2, n){
rep(j, l[i], r[i]){
int w0 = judge(j, l[i]), v0 = judge(j, r[i - 1]);
int w1 = judge(j, l[i + 1]), v1 = judge(j, r[i]);
// printf("%d : %d %d\n", j, w0, v0);
rep(p, w0, m + 1)
repd(q, v0, 0) sum[i][w1][v1] = (sum[i][w1][v1] + 1ll * sum[i - 1][p][q] * j % mod) % mod;
}
}
int ans = 0;
rep(j, 0, m + 1)
rep(k, 0, m + 1) ans = (ans + sum[n][j][k]) % mod;
printf("%d\n", ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5896kb
input:
1 2 2 0 1 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: -100
Wrong Answer
time: 68ms
memory: 78128kb
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'