QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#842092#2204. BorderliyujiaAC ✓1448ms409964kbC++14901b2025-01-04 10:13:352025-01-04 10:13:35

Judging History

你现在查看的是最新测评结果

  • [2025-01-04 10:13:35]
  • 评测
  • 测评结果:AC
  • 用时:1448ms
  • 内存:409964kb
  • [2025-01-04 10:13:35]
  • 提交

answer

#include <bits/stdc++.h>
#define F(i, j, k) for(int i = j; i <= k; i++)
#define int long long
using namespace std;
const int N = 1000005, M = 41;
int n, sd, a[N], cnt[N][M + 5], t, ans, hs[N], k[N], v[N], h[N], ne[N], c;
int add(int x){
	int t = x % 999987;
	for(int i = h[t]; ~i; i = ne[i]) if(k[i] == x) return v[i]++;
	return ne[++c] = h[t], h[t] = c, k[c] = x, v[c] = 1, 0;
}
void clr(){ memset(h, -1, sizeof h), c = 0;}
signed main(){
	cin >> n >> sd;
	F(i, 1, n) sd = (sd * 13331 + 23333) % 1000000007, a[i] = sd & 1;
	F(i, 1, M){ clr(); F(j, i, n) cnt[j][i] = add(hs[j] = hs[j] * 2 + a[j - i + 1]);}
	F(i, 1, n){
		F(j, 1, min(i, M)) hs[j] = hs[j - 1] * 2 + a[i - j + 1]; t = 0;
		for(int j = M; j; j--) if(cnt[i][j]){
			F(k, j + 1, t) if(hs[j] == (hs[k] & (1 << j) - 1)) cnt[i][j] -= cnt[i][k];
			ans += cnt[i][j] * j, t = !t? j: t;
		}
	}
	cout << ans;
	return 0;
}

Details

Test #1:

score: 100
Accepted
time: 11ms
memory: 20092kb

Test #2:

score: 0
Accepted
time: 13ms
memory: 19968kb

Test #3:

score: 0
Accepted
time: 11ms
memory: 19960kb

Test #4:

score: 0
Accepted
time: 9ms
memory: 20100kb

Test #5:

score: 0
Accepted
time: 10ms
memory: 20092kb

Test #6:

score: 0
Accepted
time: 97ms
memory: 58388kb

Test #7:

score: 0
Accepted
time: 95ms
memory: 60356kb

Test #8:

score: 0
Accepted
time: 91ms
memory: 60480kb

Test #9:

score: 0
Accepted
time: 92ms
memory: 60244kb

Test #10:

score: 0
Accepted
time: 102ms
memory: 60504kb

Test #11:

score: 0
Accepted
time: 95ms
memory: 62488kb

Test #12:

score: 0
Accepted
time: 85ms
memory: 60568kb

Test #13:

score: 0
Accepted
time: 1396ms
memory: 409924kb

Test #14:

score: 0
Accepted
time: 1405ms
memory: 409828kb

Test #15:

score: 0
Accepted
time: 1424ms
memory: 409828kb

Test #16:

score: 0
Accepted
time: 1405ms
memory: 409876kb

Test #17:

score: 0
Accepted
time: 1399ms
memory: 409828kb

Test #18:

score: 0
Accepted
time: 1411ms
memory: 409888kb

Test #19:

score: 0
Accepted
time: 1401ms
memory: 409944kb

Test #20:

score: 0
Accepted
time: 1398ms
memory: 409880kb

Test #21:

score: 0
Accepted
time: 1401ms
memory: 409880kb

Test #22:

score: 0
Accepted
time: 1401ms
memory: 409868kb

Test #23:

score: 0
Accepted
time: 1423ms
memory: 409948kb

Test #24:

score: 0
Accepted
time: 1401ms
memory: 409828kb

Test #25:

score: 0
Accepted
time: 1413ms
memory: 409868kb

Test #26:

score: 0
Accepted
time: 1410ms
memory: 409948kb

Test #27:

score: 0
Accepted
time: 1412ms
memory: 409832kb

Test #28:

score: 0
Accepted
time: 1395ms
memory: 409892kb

Test #29:

score: 0
Accepted
time: 1395ms
memory: 409952kb

Test #30:

score: 0
Accepted
time: 1424ms
memory: 409892kb

Test #31:

score: 0
Accepted
time: 1404ms
memory: 409888kb

Test #32:

score: 0
Accepted
time: 1418ms
memory: 409816kb

Test #33:

score: 0
Accepted
time: 1399ms
memory: 409824kb

Test #34:

score: 0
Accepted
time: 1391ms
memory: 409880kb

Test #35:

score: 0
Accepted
time: 1401ms
memory: 409884kb

Test #36:

score: 0
Accepted
time: 1410ms
memory: 409940kb

Test #37:

score: 0
Accepted
time: 1401ms
memory: 409952kb

Test #38:

score: 0
Accepted
time: 1394ms
memory: 409960kb

Test #39:

score: 0
Accepted
time: 1448ms
memory: 409868kb

Test #40:

score: 0
Accepted
time: 1396ms
memory: 409884kb

Test #41:

score: 0
Accepted
time: 1404ms
memory: 409956kb

Test #42:

score: 0
Accepted
time: 1390ms
memory: 409884kb

Test #43:

score: 0
Accepted
time: 1399ms
memory: 409884kb

Test #44:

score: 0
Accepted
time: 1404ms
memory: 409812kb

Test #45:

score: 0
Accepted
time: 1400ms
memory: 409868kb

Test #46:

score: 0
Accepted
time: 1409ms
memory: 409816kb

Test #47:

score: 0
Accepted
time: 1396ms
memory: 409828kb

Test #48:

score: 0
Accepted
time: 1408ms
memory: 409940kb

Test #49:

score: 0
Accepted
time: 1409ms
memory: 409828kb

Test #50:

score: 0
Accepted
time: 1392ms
memory: 409896kb

Test #51:

score: 0
Accepted
time: 1413ms
memory: 409884kb

Test #52:

score: 0
Accepted
time: 1410ms
memory: 409948kb

Test #53:

score: 0
Accepted
time: 1416ms
memory: 409964kb

Test #54:

score: 0
Accepted
time: 1408ms
memory: 409816kb

Test #55:

score: 0
Accepted
time: 1416ms
memory: 409816kb