QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628096 | #9346. Binary Numbers | liuyz11 | WA | 16ms | 14192kb | C++20 | 1.6kb | 2024-10-10 18:33:25 | 2024-10-10 18:33:26 |
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 = 1e6 + 5;
const int MAXM = 25;
const int mod = 1e9 + 7;
int dp[MAXN], sum[MAXN][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;
}
return -1;
}
int main(){
int t;
scanf("%d", &t);
while(t--){
int n, m;
scanf("%d%d", &m, &n);
int M = (1 << m) - 1;
rep(i, 1, M) dp[i] = 0;
rep(i, 1, n){
rep(j, 1, m - 1) sum[i][j] = 0;
}
rep(i, 1, n){
scanf("%d%d", &l[i], &r[i]);
}
rep(i, l[1], r[1]){
dp[i] = i;
int w = judge(i, r[1] + 1);
sum[1][w] = (sum[1][w] + dp[i]) % mod;
// printf("%d 1 : %d %d\n", i, w, sum[1][w]);
}
int j = 1;
rep(i, r[1] + 1, M){
while(j < n && r[j] < i) j++;
int v = judge(i, l[j]);
// printf("%d %d : %d %d\n", i, j, v, dp[i]);
rep(k, v + 1, 19) dp[i] = (dp[i] + sum[j - 1][k]) % mod;
// printf("%d %d : %d %d\n", i, j, v, dp[i]);
dp[i] = 1ll * dp[i] * i% mod;
}
int ans = 0;
rep(i, l[n], r[n]) ans = (ans + dp[i]) % mod;
printf("%d\n", ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10088kb
input:
1 2 2 0 1 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: -100
Wrong Answer
time: 16ms
memory: 14192kb
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:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 28 0
result:
wrong answer 1st lines differ - expected: '430920', found: '0'