QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#775864 | #9791. Intrusive Donkey | ucup-team191# | WA | 2ms | 7808kb | C++23 | 2.0kb | 2024-11-23 16:54:26 | 2024-11-23 16:54:27 |
Judging History
answer
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair < int, ll > pil;
const int N = 2e5 + 500;
const int OFF = (1 << 18);
int n, q;
ll T[2 * OFF];
int prop[2 * OFF];
char s[N];
void refresh(int i) {
if(!prop[i]) return;
T[i] <<= prop[i];
if(i < OFF) {
prop[2 * i] += prop[i];
prop[2 * i + 1] += prop[i];
}
}
void update(int i, int a, int b, int lo, int hi) {
if(lo <= a && b <= hi) {
prop[i]++; refresh(i); return;
}
refresh(i);
if(a > hi || b < lo) return;
update(2 * i, a, (a + b) / 2, lo, hi);
update(2 * i + 1, (a + b) / 2 + 1, b, lo, hi);
T[i] = T[2 * i] + T[2 * i + 1];
}
pil find_index(int i, ll kol) {
if(!(i - 1)) refresh(i);
if(i >= OFF) return {i - OFF, kol};
refresh(2 * i); refresh(2 * i + 1);
if(T[2 * i] <= kol) return find_index(2 * i + 1, kol - T[2 * i]);
return find_index(2 * i, kol);
}
void postavi(int i, int a, int b, int pos, ll kol) {
if(!(i - 1)) refresh(i);
if(a == b) {
T[i] = kol;
return;
}
refresh(2 * i); refresh(2 * i + 1);
if(pos <= (a + b) / 2) postavi(2 * i, a, (a + b) / 2, pos, kol);
else postavi(2 * i + 1, (a + b) / 2 + 1, b, pos, kol);
T[i] = T[2 * i] + T[2 * i + 1];
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> q;
for(int i = 0;i < n;i++) {
cin >> s[i];
T[OFF + i] = 1;
}
for(int i = OFF - 1; i ; i--) T[i] = T[2 * i] + T[2 * i + 1];
for(;q--;) {
int ty; cin >> ty;
if(ty == 2) {
ll pos; cin >> pos; pos--;
cout << s[find_index(1, pos).X] << '\n';
} else {
ll l, r; cin >> l >> r; l--, r--;
pil L = find_index(1, l);
pil R = find_index(1, r);
if(L.X == R.X) {
postavi(1, 0, OFF - 1, L.X, T[OFF + L.X] + (r - l + 1));
} else {
postavi(1, 0, OFF - 1, L.X, 2 * T[OFF + L.X] - L.Y);
postavi(1, 0, OFF - 1, R.X, T[OFF + R.X] + R.Y + 1);
update(1, 0, OFF - 1, L.X + 1, R.X - 1);
}
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 7736kb
input:
4 7 abac 2 2 2 3 1 2 3 2 3 2 4 2 5 2 6
output:
b a b a a c
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 7748kb
input:
5 4 shrek 1 1 2 2 7 1 1 7 2 7
output:
k h
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 7612kb
input:
4 7 abac 2 2 2 3 1 2 3 2 3 2 4 2 5 2 6
output:
b a b a a c
result:
ok 6 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 7672kb
input:
5 4 shrek 1 1 2 2 7 1 1 7 2 7
output:
k h
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 7616kb
input:
3 55 vfe 1 2 3 1 2 2 1 3 5 2 4 1 1 2 2 9 2 7 2 5 1 10 10 1 1 1 2 9 1 8 12 2 8 1 7 10 2 1 1 5 6 1 1 4 1 20 24 1 14 32 1 19 38 2 48 1 56 64 2 58 2 19 1 64 72 1 36 86 2 11 1 117 124 2 38 2 108 2 85 1 112 118 2 153 2 40 2 114 2 80 1 11 18 2 27 2 73 1 159 162 2 84 1 130 164 2 163 2 65 1 150 156 1 101 109...
output:
f e f f f f v f e f f f e e e f e e f e e e f e f e v
result:
ok 27 lines
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 7808kb
input:
60 51 ranhfkbjhkxckkcbhgsspsjcbjgpwcfvmqqlvlfualndmqqsihsfdyqviowu 2 53 2 37 2 33 2 60 1 1 32 2 44 1 87 92 1 7 77 1 56 86 2 17 1 128 184 1 26 159 2 323 2 55 1 24 316 1 435 652 2 316 2 444 1 819 868 2 27 2 912 2 313 1 555 576 1 510 942 1 1118 1269 2 365 2 84 1 595 650 2 1468 2 258 1 1557 1607 2 938 1...
output:
d v m u s n n n
result:
wrong answer 6th lines differ - expected: 'k', found: 'n'