QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749971 | #4900. 数列重排 | NineSuns | 35 | 130ms | 4316kb | C++14 | 1.8kb | 2024-11-15 11:47:13 | 2024-11-15 11:47:20 |
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, n;
string str;
inline int sum (int n) { return n*(n+1)/2; }
inline int gets (int k, int c) {
return sum(k/c)*c+(k/c+1)*(k%c);
}
inline 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';
}
int lt = 1, res = 0, k = 0;
if (L == 0) res ^= sum(n)%mod;
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 sv;
// for (int j = 0;j <= sl;j++) cout << gv(i, sl, cx, j) << " " ;cout << endl;
if (cx > 1) {
int ml = (2*sl+i*cx-i)/(cx+1);
sv = inf;
for (int j = max(0ll, ml-19);j <= min(sl, ml+19);j++) sv = min(sv, gv(i, sl, cx, j));
//// 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;
// }
// sv = gv(i, sl, cx, l);
}
else sv = -sl*i+gets(sl , 2);
ans += sv+2*i*sl+i*(i+1)*(cx-1)+sum(i)+i;
ans = sum(n)-ans;
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;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 3628kb
input:
2 0 2 2 01
output:
541257
result:
ok 1 number(s): "541257"
Test #2:
score: 5
Accepted
time: 0ms
memory: 3708kb
input:
4 1 4 2 00001
output:
525797597
result:
ok 1 number(s): "525797597"
Test #3:
score: 5
Accepted
time: 0ms
memory: 3712kb
input:
9 0 9 1 000000000
output:
711136343
result:
ok 1 number(s): "711136343"
Test #4:
score: 5
Accepted
time: 0ms
memory: 3580kb
input:
1 0 1 9 0
output:
10456
result:
ok 1 number(s): "10456"
Test #5:
score: 5
Accepted
time: 0ms
memory: 3624kb
input:
2 1 2 3 11
output:
1518844
result:
ok 1 number(s): "1518844"
Subtask #2:
score: 15
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 15
Accepted
time: 0ms
memory: 3712kb
input:
21 0 21 9 111010011100100100000
output:
171658329
result:
ok 1 number(s): "171658329"
Test #7:
score: 15
Accepted
time: 0ms
memory: 3552kb
input:
200 0 200 1 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
output:
287932632
result:
ok 1 number(s): "287932632"
Test #8:
score: 15
Accepted
time: 0ms
memory: 3700kb
input:
120 3 119 1 101000110101001100011100001011101110101010000011101110010101101000111100111100001001010010110001110011001010110001101111
output:
856785458
result:
ok 1 number(s): "856785458"
Test #9:
score: 15
Accepted
time: 0ms
memory: 3560kb
input:
2 0 2 99 10
output:
67513337
result:
ok 1 number(s): "67513337"
Subtask #3:
score: 0
Wrong Answer
Dependency #2:
100%
Accepted
Test #10:
score: 15
Accepted
time: 0ms
memory: 3712kb
input:
10 1 9 499 0110011010
output:
47418354
result:
ok 1 number(s): "47418354"
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
input:
100 0 100 49 1100100011111101111111001000000100010000101010110000011011110100100011111000111101100010001000001100
output:
152882043
result:
wrong answer 1st numbers differ - expected: '100314042', found: '152882043'
Subtask #4:
score: 5
Accepted
Test #14:
score: 5
Accepted
time: 0ms
memory: 3556kb
input:
2 0 1 114514 10
output:
934764137
result:
ok 1 number(s): "934764137"
Test #15:
score: 5
Accepted
time: 0ms
memory: 3548kb
input:
2 0 1 1919810 01
output:
685371514
result:
ok 1 number(s): "685371514"
Test #16:
score: 5
Accepted
time: 0ms
memory: 3580kb
input:
2 0 1 500000000 00
output:
318651831
result:
ok 1 number(s): "318651831"
Subtask #5:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 130ms
memory: 4304kb
input:
1000000 1000000 1000000 928 01100010010000000101111110001111011101111000011110100101011110011001001000011000110101101100111110000100101010111001111100010011100110000000111110110100001100000000011101100001010001010000010000001001000110011111010101111100001001110110010100000011000010010001111010011100...
output:
-761598951
result:
wrong answer 1st numbers differ - expected: '437299311', found: '-761598951'
Subtask #6:
score: 10
Accepted
Test #19:
score: 10
Accepted
time: 8ms
memory: 4232kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
852768823
result:
ok 1 number(s): "852768823"
Test #20:
score: 10
Accepted
time: 8ms
memory: 4316kb
input:
1000000 0 1000000 1 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
852768823
result:
ok 1 number(s): "852768823"
Subtask #7:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 126ms
memory: 4260kb
input:
1000000 0 9823 627 01110001011101001100010011100101001011000011011110001101010000000101010111110111110010010001110100101001111000111100011101111001000000100111000010010100010101110110111110100010101010001110111001100011010001111000101010000110010010101110101010111110110001110111111000001110000110011...
output:
121646068
result:
wrong answer 1st numbers differ - expected: '383638431', found: '121646068'
Subtask #8:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%