QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628385 | #9346. Binary Numbers | liuyz11 | WA | 57ms | 57572kb | C++20 | 1.7kb | 2024-10-10 19:55:53 | 2024-10-10 19:55:53 |
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 = 1.5e5 + 5;
const int MAXM = 21;
const int mod = 1e9 + 7;
int n, m;
int sum[MAXN][MAXM][MAXM], l[MAXN], r[MAXN];
int judge(int x, int y){
int s = 0;
// printf("%d %d %d\n", x, y, res);
repd(i, m - 1, 0){
if((x >> i & 1) == (y >> i & 1)) s++;
else break;
}
return s;
}
int main(){
// rep(i, 1, 100){
// rep(j, i, 100) printf("%d ", judge(i, j));
// puts("");
// }
int t;
scanf("%d", &t);
while(t--){
scanf("%d%d", &m, &n);
rep(i, 0, n){
rep(j, 0, 20)
rep(k, 0, 20) sum[i][j][k] = 0;
}
rep(i, 1, n){
scanf("%d%d", &l[i], &r[i]);
}
sum[0][0][m] = 1;
rep(i, 1, n){
rep(j, l[i], r[i]){
int w0 = judge(j, l[i]), v0 = judge(j, r[i - 1]);
if(i == 1) v0 = 0;
int w1 = judge(j, l[i + 1]), v1 = judge(j, r[i]);
if(i == n) w1 = 0;
// printf("%d : %d %d\n", j, w0, v0);
int s = 0;
repd(p, w0, 0)
rep(q, v0, m) s = (s + sum[i - 1][p][q]) % mod;
sum[i][w1][v1] = (sum[i][w1][v1] + 1ll * s * j % mod) % mod;
}
}
int ans = 0;
rep(j, 0, m)
rep(k, 0, m) 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: 1ms
memory: 5936kb
input:
1 2 2 0 1 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: -100
Wrong Answer
time: 57ms
memory: 57572kb
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'