QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#81948 | #5516. Modern Machine | zhouhuanyi | 11 | 101ms | 17492kb | C++23 | 2.1kb | 2023-02-26 19:02:58 | 2023-02-26 19:02:59 |
Judging History
answer
#include<iostream>
#include<cstdio>
#define N 10
#define M 120000
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
struct reads
{
int p[N+1];
};
char c[N+1],cs[N+1];
int n,m,q,res,a[N+1],A[M+1];
reads tmp,delta[N+1];
reads operator + (reads a,reads b)
{
for (int i=0;i<=n;++i) tmp.p[i]=b.p[a.p[i]];
return tmp;
}
struct seg
{
struct node
{
int l,r;
reads data;
};
node tree[(M<<2)+1];
void push_up(int k)
{
tree[k].data=tree[k<<1].data+tree[k<<1|1].data;
return;
}
void build(int k,int l,int r)
{
tree[k].l=l,tree[k].r=r;
if (l==r)
{
tree[k].data=delta[A[l]];
return;
}
int mid=(l+r)>>1;
build(k<<1,l,mid),build(k<<1|1,mid+1,r),push_up(k);
return;
}
reads query(int k,int l,int r)
{
if (tree[k].l==l&&tree[k].r==r) return tree[k].data;
int mid=(tree[k].l+tree[k].r)>>1;
if (r<=mid) return query(k<<1,l,r);
else if (l>=mid+1) return query(k<<1|1,l,r);
else return query(k<<1,l,mid)+query(k<<1|1,mid+1,r);
}
};
seg T;
int main()
{
int l,r,sl,sr,op,cnt;
n=read(),m=read();
for (int i=1;i<=n;++i) cin>>c[i];
for (int i=1;i<=m;++i) A[i]=read();
for (int i=1;i<=n;++i)
for (int j=0;j<=n;++j)
{
for (int k=1;k<=n;++k) cs[k]=(k<=j)?'R':'B';
sl=sr=i,cs[i]='R',op=cnt=0;
while (1)
{
if (!op)
{
if (sr==n)
{
op=1;
break;
}
else if (cs[sr+1]=='R') sr++;
else sr++,op=1;
}
else
{
if (sl==1)
{
op=0;
break;
}
else if (cs[sl-1]=='B') sl--;
else sl--,op=0;
}
}
if (!op)
{
for (int i=sl;i<=sr;++i) cs[i]='R';
}
else
{
for (int i=sl;i<=sr;++i) cs[i]='B';
}
for (int k=1;k<=n;++k) cnt+=(cs[k]=='R');
delta[i].p[j]=cnt;
}
T.build(1,1,m),q=read();
while (q--) l=read(),r=read(),printf("%d\n",T.query(1,l,r).p[n]);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3440kb
input:
3 1 BBR 3 1 1 1
output:
2
result:
wrong answer 1st lines differ - expected: '0', found: '2'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 11
Accepted
Test #21:
score: 11
Accepted
time: 95ms
memory: 17492kb
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:
10 6 1 8 1 9 8 1 3 0 3 4 4 2 2 2 10 8 10 7 0 7 0 1 10 3 10 7 3 2 10 8 10 0 0 10 1 2 5 4 0 7 1 0 6 7 6 8 3 2 4 7 0 6 7 5 2 8 4 8 1 4 4 10 3 7 7 7 3 1 3 10 3 4 0 2 1 3 9 8 4 6 10 9 3 7 9 2 5 7 2 7 2 1 0 6 0 6 3 6 2 8 1 10 9 4 5 2 5 10 9 4 1 8 5 3 6 3 8 9 10 6 4 10 7 2 8 7 9 7 7 0 9 5 5 6 3 7 4 7 9 6 7...
result:
ok 120000 lines
Test #22:
score: 0
Accepted
time: 101ms
memory: 17292kb
input:
10 120000 RRRRRRRRRR 5 3 4 3 3 4 3 7 7 7 6 9 4 10 10 9 9 7 8 8 9 4 8 9 5 8 4 8 8 6 4 10 9 4 8 6 3 1 7 8 1 7 5 5 1 6 4 5 1 1 9 1 5 6 9 7 4 5 8 10 3 2 3 10 2 9 8 3 3 5 5 9 5 7 10 6 2 6 9 10 5 3 1 6 2 8 1 1 3 9 3 6 9 7 6 8 8 4 7 9 8 8 6 6 7 7 8 4 9 5 9 9 3 4 8 1 6 6 10 7 2 10 8 10 5 4 5 8 7 5 5 7 2 9 8...
output:
3 0 7 8 10 10 8 2 7 10 4 8 7 10 8 5 1 0 3 7 4 10 7 5 7 1 0 7 7 7 5 7 5 8 0 3 8 3 6 6 3 6 6 0 2 8 5 5 4 9 10 6 6 3 7 10 3 1 4 2 2 9 2 5 4 7 1 7 7 0 10 3 2 0 0 1 0 10 1 5 8 6 8 1 4 0 10 9 5 3 7 5 7 3 5 7 4 0 4 1 8 4 4 8 0 10 0 5 1 3 2 9 2 7 6 0 8 4 6 3 2 6 3 4 10 1 3 8 3 9 6 5 3 2 0 3 0 5 5 10 1 3 2 6...
result:
ok 120000 lines
Test #23:
score: 0
Accepted
time: 94ms
memory: 17284kb
input:
10 120000 RRRRRRRRRR 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...
output:
9 5 9 2 9 8 9 9 7 6 9 9 9 6 7 9 9 7 5 9 9 9 9 9 3 9 9 7 7 2 9 9 9 9 7 3 7 7 7 5 9 9 9 6 9 9 7 9 7 9 9 9 9 9 9 9 9 6 9 9 9 9 9 9 2 9 5 6 7 7 7 9 2 9 9 2 9 9 9 2 9 2 9 9 5 7 7 6 2 9 9 7 9 8 2 9 9 2 9 9 9 9 7 9 9 9 9 6 9 8 7 8 7 7 2 7 7 6 9 9 6 9 9 9 2 3 2 9 9 9 9 9 9 9 7 7 9 9 9 6 9 9 7 7 7 9 7 2 9 7 ...
result:
ok 120000 lines
Test #24:
score: 0
Accepted
time: 36ms
memory: 17428kb
input:
10 120000 RRRRRRRRRR 9 1 5 3 5 6 4 7 4 3 2 2 5 3 1 8 6 6 2 4 7 5 5 4 8 4 7 10 1 4 7 6 8 4 9 2 9 9 6 6 2 1 8 6 3 8 6 7 9 10 7 10 5 10 10 1 4 10 9 8 7 1 6 5 2 8 3 6 9 5 7 4 4 9 9 9 1 5 4 3 6 1 4 1 8 10 7 2 10 1 5 3 2 3 2 6 2 9 5 1 5 6 3 1 9 8 1 4 5 8 8 10 6 2 8 4 2 7 5 9 2 10 2 8 10 7 3 5 3 9 5 9 3 9 ...
output:
8 9 3 6 0 7 0 8 1 5 7 9 3 6 7 5 1 8 10 3 0 6 0 5 3 8 4 4 5 9 5 1 10 3 2 4 3 2 9 4 6 7 5 1 5 3 10 6 5 5 2 2 8 8 8 9 2 2 1 10 6 7 2 8 10 7 10 5 4 10 6 10 3 2 1 0 2 8 1 5 1 2 7 8 5 5 2 4 4 5 10 2 4 7 9 4 6 5 10 0 6 1 5 6 5 3 4 8 2 0 9 9 4 6 4 8 10 6 0 10 1 1 4 2 2 10 2 8 0 10 4 3 6 5 8 4 7 1 8 0 0 5 5 ...
result:
ok 120000 lines
Test #25:
score: 0
Accepted
time: 29ms
memory: 17248kb
input:
10 120000 RRRRRRRRRR 3 7 3 1 1 4 4 5 6 8 9 7 1 3 6 5 9 9 7 2 1 10 1 7 2 5 10 7 10 2 8 3 2 8 6 5 7 10 1 1 9 10 3 1 8 7 4 6 3 7 8 5 8 8 10 5 9 1 2 8 7 1 6 6 8 9 9 3 5 7 6 8 10 9 1 7 10 1 10 8 7 4 2 7 3 7 9 5 3 3 3 5 1 4 1 5 8 1 2 5 2 7 8 3 4 3 3 8 8 8 6 1 5 2 2 6 2 1 5 6 8 1 8 10 4 3 4 8 5 5 5 1 4 6 1...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 120000 lines
Subtask #5:
score: 0
Runtime Error
Test #26:
score: 0
Runtime Error
input:
120000 120000 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
output:
result:
Subtask #6:
score: 0
Runtime Error
Test #30:
score: 0
Runtime Error
input:
120000 120000 RRBBRBRBBBRBRRBRBRRRBRBRRBRRRBBRBBBBBBRBBRBRBRBRRBRBRBRRRBRBBBBRRBBRRBBRRRBRRBRBBRRRBBBRRBBBBRBBBRBBBRBBBRBBRBBBBRBBBBRRBRRRRRRRBRRRBRBBBRBBBBRBBRBRBRRBBRRBRBBBBRBBBRBBRRBBBBRBBBBRBRRBRBBRBBBBRRBBBBBBRBBRBBBBBBRBBRRRRRBBBRBBBRBRRBBRBRBRBBRRBRRBBBRBRBRRRBBRRBBRRRRBRRBBRRBBBBBBBRBBBRBBBR...
output:
result:
Subtask #7:
score: 0
Skipped
Dependency #1:
0%