QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#365084 | #5516. Modern Machine | ksu_ | 15 | 25ms | 3952kb | C++23 | 2.7kb | 2024-03-24 19:18:45 | 2024-03-24 19:18:45 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,sse3")
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef long long ll;
#define endl '\n'
ll n, m;
string simulation(string a, ll p){
a[p] = 'R';
while(p >= 1 && p <= n){
if(a[p] == 'R'){
a[p] = 'B';
p++;
}
else{
a[p] = 'R';
p--;
}
}
return a;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
string a;
cin >> a;
for(auto &i: a)
i = (i == 'R' ? '>' : '<');
a = "#" + a;
vector<ll> d(m + 1);
for(int i = 1; i <= m; i++)
cin >> d[i];
ll q;
cin >> q;
auto a0 = a;
while(q--){
ll l, r;
cin >> l >> r;
a = a0;
for(int i = l; i <= r; i++){
ll left0 = 0, right = 0;
ll p = d[i];
for(int j = 1; j < p; j++)
if(a[j] == '>')
left0++;
for(int j = p + 1; j <= n; j++)
if(a[j] == '<')
right++;
if(left0 >= right){
// sufix to '<'
ll need = right;
ll cur = p;
for(int j = p - 1; j >= 1 && need > 0; j--){
if(a[j] == '>'){
need--;
cur = j;
}
}
for(int j = cur; j <= n; j++)
a[j] = '<';
}
else{
// prefix to '>'
ll need = left0 + 1;
ll cur = p;
for(int j = p + 1; j <= n && need > 0; j++){
if(a[j] == '<'){
need--;
cur = j;
}
}
for(int j = 1; j <= cur; j++)
a[j] = '>';
}
}
ll ans = 0;
for(int i = 1; i <= n; i++)
ans += (a[i] == '>');
cout << ans << endl;
}
return 0;
}
/*
5 3
RBRBR
1 3 4
1
2 3
*/
詳細信息
Subtask #1:
score: 3
Accepted
Test #1:
score: 3
Accepted
time: 0ms
memory: 3872kb
input:
3 1 BBR 3 1 1 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
3 10 BBB 3 3 3 1 3 3 3 3 3 1 1 2 5
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
10 1 RBBBBRRBBR 9 1 1 1
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
10 10 RRRBBRRBRB 5 9 4 6 7 7 4 3 8 2 1 1 10
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
300 300 BRRRRBBRBRBRBBBRBRRRBRBBRBBRRBBRBBRBRBRBRBBRRBBRBBRBBBBRRRRBRBRBBBBRBBBRBBRBBRBRBRRBRBBRRRRBRBBRRRBRRBRBBBRRRRBRRRBBBBRRBBRBBBRRRBRBBRBRBBRRBRBRRRBRBRBBBBRRBRBRRRRRBRRRRRBRRRBRBRRRRRBBBRRBBRBBRRRRBBBBRBRBBBRRRRBBBBBBBBBBRBRRBRBBRRRRBRBBRRRBBRBRRRBBRBRRBBRBBBBRBRBRBBBRBBRBRBBRBBRBRBRBRRRBBBBR...
output:
29
result:
ok single line: '29'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
300 300 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
149
result:
ok single line: '149'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
5 2 RBRBB 2 5 1 1 2
output:
4
result:
ok single line: '4'
Subtask #2:
score: 12
Accepted
Dependency #1:
100%
Accepted
Test #8:
score: 12
Accepted
time: 11ms
memory: 3688kb
input:
7000 7000 RRBRRRRRRBBRBRBRRRBRRRBRRRRBRBRBRBRBBBRBRRRBBBRBBBBBBRBBBRRBRBRBBRRRBBBBRRBBRBBRBBRRRBBRRBRBRRRRRBBRRBRBBBRBBRRRRBRBBBBRBBBBBBRRRBRBRBBRBRRBBBBBRRBBBBBBRBBBRRBBRRBBBBBBRBRBRBBRBBRBBBRRBRBBRBBBBBRBRRBRRBRRRBRBBBBBRRBRBRRBRRRRBBBBRRBBRRRRRBBBBBRRBBBBBBRRBBRBRRRRRRRBRRBRRBBBBBBBBRRRRBBRRRRRRR...
output:
5505
result:
ok single line: '5505'
Test #9:
score: 0
Accepted
time: 8ms
memory: 3720kb
input:
7000 7000 RRBRRRBBRRBBRBBBBRBRBRRBBBBBBBBBBRRRBRRBBRRRRBBRRBRRRRRBBRBBBBBRRBBBBRBBBBRBRBBBBBRBBRRRBBBBRRBRRBRRBRBBBRRRRBBRRBRRBRBBRBBBRBBBRRBRBBBRRBBBBBRBBRBRBRBBBBRRBBBRRRRBRRBBRBRBBBBBBRRRRRBBRRBBRRBBBRBBBRRRRRBRBBRBRBBRRBBRBRRRBBRRBBBRRBRRRRRRRBBRBRRBRBRBRBRBRBBRBRRBRBBBBBBBRRBRRRBBBBRRBBRRRBBRBR...
output:
5936
result:
ok single line: '5936'
Test #10:
score: 0
Accepted
time: 18ms
memory: 3880kb
input:
7000 7000 RBBRBRBRRRBBRBRRBRBBRBRRRBRBBBRBBRBRBRBRRBBBBRBRRRBBRRRRBBRRRRBBRBRBRRRRBBRRBBRBRBBBRBBBBBRBBRBBRRBBRRRRRBBRBRBRRBBRRRBRBBBRBRRBRRRBRRRBRBBBBRBBBBBBRBRRRBRRRBRBBBRBRRBBRRBRRBBBBBRBBRRRRBBRRBBBBRRBRBRRRRBBRRRRRBRBRRBBRRRRRBRRBRBBBBRRBBBBRBRRRBBRBRRRRRBRRBRRRBRRBRRRRRBBBRBBBRBRRRBRBBBBRRRRRR...
output:
6260
result:
ok single line: '6260'
Test #11:
score: 0
Accepted
time: 25ms
memory: 3648kb
input:
7000 7000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
output:
3499
result:
ok single line: '3499'
Test #12:
score: 0
Accepted
time: 21ms
memory: 3952kb
input:
7000 7000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
3906
result:
ok single line: '3906'
Subtask #3:
score: 0
Time Limit Exceeded
Dependency #2:
100%
Accepted
Test #13:
score: 0
Time Limit Exceeded
input:
120000 120000 BBBBRBBRBRRBRRRBBBRRRRRBRRRRRRRRRRRBBBBRBRBBBBBBRBRBBBRBBRBRRBBRBRRRBRBBBBBRBRRBBRRRRRBBRBBBBRBBRRBRRRRBRBBBRRRBBBRRBRRBBBRRRBRRRBBRBBRRRBBBRBBRBBBBBRBRRRRBBRBRBRBBRRRRRRRBBRRBBBBRRRBBRRRRRBBBBRBBBBRBRRBBBRBRBBBRBRBRRBBRBRBBBRRBBRBBBBRBBRRBRBRBRBRRBBRBBBBBBBRRRRBRBRBRBRRRRBRRBBBRBRRBRB...
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #21:
score: 0
Time Limit Exceeded
input:
10 120000 RRRRRRRRRR 9 1 9 6 1 9 6 10 3 2 6 4 2 5 7 10 8 9 2 6 7 10 2 9 7 5 9 9 2 7 4 1 8 3 3 6 9 4 7 9 6 8 8 2 5 6 8 3 9 2 5 2 5 9 8 4 8 3 2 2 5 1 9 1 7 9 9 4 9 5 2 10 7 4 3 8 1 10 7 6 6 2 3 8 7 8 5 9 2 2 1 10 2 2 5 4 2 5 9 1 8 4 5 1 2 8 3 10 10 6 7 2 1 5 10 1 9 10 1 7 3 10 8 10 6 8 3 1 10 9 10 5 5...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #26:
score: 0
Time Limit Exceeded
input:
120000 120000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
output:
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #30:
score: 0
Time Limit Exceeded
input:
120000 120000 RRBBRBRBBBRBRRBRBRRRBRBRRBRRRBBRBBBBBBRBBRBRBRBRRBRBRBRRRBRBBBBRRBBRRBBRRRBRRBRBBRRRBBBRRBBBBRBBBRBBBRBBBRBBRBBBBRBBBBRRBRRRRRRRBRRRBRBBBRBBBBRBBRBRBRRBBRRBRBBBBRBBBRBBRRBBBBRBBBBRBRRBRBBRBBBBRRBBBBBBRBBRBBBBBBRBBRRRRRBBBRBBBRBRRBBRBRBRBBRRBRRBBBRBRBRRRBBRRBBRRRRBRRBBRRBBBBBBBRBBBRBBBR...
output:
result:
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%