QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#749871 | #4900. 数列重排 | NineSuns | 30 | 447ms | 13824kb | C++14 | 1.8kb | 2024-11-15 11:04:24 | 2024-11-15 11:04:24 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define int long long
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e7+5, inf = 0x3f3f3f3f3f3f3f3f, mod = 998244353;
int m, L, R, x, pr[N], n;
string str;
int sum (int n) { return n*(n+1)/2; }
int gets (int k, int c) {
if (c == 0 && k) return inf;
if (c == 0) return 0;
return sum(k/c)*(c-k%c)+sum(k/c+1)*(k%c);
}
int gv (int i, int sl, int cx, int j) {
return -j*i+gets(j, 2)+gets(sl-j, cx-1);
}
void solve () {
cin >> m >> L >> R >> x >> str;
n = m*x;
for (int i = 0;i < m;i++) {
n += str[i]-'0';
pr[i] = str[i] == '1' ? (i ? pr[i-1]+1 : 1) : 0;
}
// cout << n << end l;
int lt = 1, res = 0, k = 0;
if (L == 0) res ^= sum(n)%mod;
// cout << sum(n) << endl;
for (int i = 0;i < m;i++) {
lt = lt*233%mod;
if (str[i] == '1') k++;
int ans = 0, sl, cx;
if (k == i+1) {
sl = n-(i+1)*(x+1); cx = x+1;
}
else {
sl = n-(i+1)*x-k; cx = x;
ans += k*i;
}
int l = 0, r = sl;
while (l < r) {
int mid = l+r+1>>1;
if (gv(i, sl, cx, mid)-gv(i, sl, cx, mid-1) <= 0) l = mid;
else r = mid-1;
}
int sv = gv(i, sl, cx, l);
// for (int j = 0;j <= sl;j++) cout << gv(i, sl, cx, j) << " "; cout << endl;
// cout << sv << endl;
// cout << l << " " << sv << endl;
ans += sv+2*i*sl+i*(i+1)*(cx-1)+sum(i)+i;
ans = sum(n)-ans;
// cout << "RES:" << i << " " << ans << " " << lt << " " << res << endl;
if (L <= i+1 && i+1 <= R) res ^= ans%mod*lt%mod;
}
cout << res;
}
signed main () {
// freopen("t.out", "w" ,stdout);
// ios::sync_with_stdio(0);
// cin.tie(0); cout.tie(0);
int T = 1; //cin >> T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 3572kb
input:
2 0 2 2 01
output:
541257
result:
ok 1 number(s): "541257"
Test #2:
score: 5
Accepted
time: 0ms
memory: 3784kb
input:
4 1 4 2 00001
output:
525797597
result:
ok 1 number(s): "525797597"
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
9 0 9 1 000000000
output:
-854409697
result:
wrong answer 1st numbers differ - expected: '711136343', found: '-854409697'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 5
Accepted
Test #14:
score: 5
Accepted
time: 0ms
memory: 3640kb
input:
2 0 1 114514 10
output:
934764137
result:
ok 1 number(s): "934764137"
Test #15:
score: 5
Accepted
time: 0ms
memory: 3564kb
input:
2 0 1 1919810 01
output:
685371514
result:
ok 1 number(s): "685371514"
Test #16:
score: 5
Accepted
time: 0ms
memory: 3716kb
input:
2 0 1 500000000 00
output:
318651831
result:
ok 1 number(s): "318651831"
Subtask #5:
score: 10
Accepted
Test #17:
score: 10
Accepted
time: 445ms
memory: 13212kb
input:
1000000 1000000 1000000 928 01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...
output:
437299311
result:
ok 1 number(s): "437299311"
Test #18:
score: 10
Accepted
time: 0ms
memory: 3636kb
input:
100 100 100 10000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
output:
119118463
result:
ok 1 number(s): "119118463"
Subtask #6:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 183ms
memory: 13208kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
-752786140
result:
wrong answer 1st numbers differ - expected: '852768823', found: '-752786140'
Subtask #7:
score: 15
Accepted
Test #21:
score: 15
Accepted
time: 432ms
memory: 12492kb
input:
1000000 0 9823 627 01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...
output:
383638431
result:
ok 1 number(s): "383638431"
Test #22:
score: 15
Accepted
time: 446ms
memory: 13480kb
input:
1000000 456755 465755 982 0100111111100111100010100011110111111101011111101110010011101011110011111010110000110001101001011101000110111100110100101111101011111010101011101000011101100000000111000010101011011000111010101101111011100101010010000110101011110010101011111101110101100010000100001110000100...
output:
982882798
result:
ok 1 number(s): "982882798"
Test #23:
score: 15
Accepted
time: 1ms
memory: 3576kb
input:
1000 0 1000 999999 11101000001100101110100011011111010000110101000000010101111010110110100110000001101110100011010111001000000010110101110001010111101000100010010010110000000001011110010010101111110000100001000111000010110001100100011100001000111001110110001010100000110110000110001111101101000010111...
output:
337235666
result:
ok 1 number(s): "337235666"
Test #24:
score: 15
Accepted
time: 447ms
memory: 13824kb
input:
1000000 990001 1000000 999 110110000110101111001000001001011000010000101001111110001101100011001001111001010001110110010111110100000101110000101101000111001100010100010100001001001011011100001010111100110110011001110010001110011001111100011001100111110000111011011100100100011111101100011000100011011...
output:
794028825
result:
ok 1 number(s): "794028825"
Subtask #8:
score: 0
Skipped
Dependency #1:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%