QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#232719 | #5414. Stop, Yesterday Please No More | xukuan | WA | 3ms | 6492kb | C++14 | 1.8kb | 2023-10-30 20:43:47 | 2023-10-30 20:43:48 |
Judging History
answer
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const ll N=1010,M=1000010;
ll T,n,m,k,len,L,R,U,D,ans,sum[N<<1][N<<1];
char s[M];
struct node{
ll x,y;
}now;
vector<node> hole;
inline ll calc(ll x1,ll Y1,ll x2,ll y2){
return sum[x2][y2]-sum[x1-1][y2]-sum[x2][Y1-1]+sum[x1-1][Y1-1];
}
inline void clean(){
ans=0;
for(ll i=0; i<=n*2+1; i++){
for(ll j=0; j<=m*2+1; j++) sum[i][j]=0;
}
while(!hole.empty()) hole.pop_back();
}
int main(){
scanf("%lld",&T);
while(T--){
clean();
scanf("%lld %lld %lld",&n,&m,&k);
scanf("%s",s+1); len=strlen(s+1);
now.x=1; now.y=1;
L=1; R=n; U=1; D=m;
for(ll i=1; i<=len; i++){
switch(s[i]){
case 'U':{
now.x++;
U=max(now.x,U);
break;
}
case 'D':{
now.x--;
D=min(now.x+n-1,D);
break;
}
case 'L':{
now.y++;
L=max(now.y,L);
break;
}
case 'R':{
now.y--;
R=min(now.y+m-1,R);
break;
}
default:while(1);
}
hole.push_back(node{now.x-1,now.y-1});
}
//cout<<'L'<<L<<'R'<<R<<'U'<<U<<'D'<<D<<endl;
hole.push_back(node{0,0});
ll val=max(R-L+1,0ll)*max(D-U+1,0ll);
if(val<k){
printf("0\n");
continue;
}
if(val==0){
printf("%lld\n",n*m);
continue;
}
for(ll i=0; i<(ll)hole.size(); i++){
if(hole[i].x>=-n&&hole[i].x<=n&&hole[i].y>=-m&&hole[i].y<=m){
sum[hole[i].x+n][hole[i].y+m]=1;
}
}
for(ll i=1; i<=n*2+1; i++){
for(ll j=1; j<=m*2+1; j++){
sum[i][j]+=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
}
}
for(ll x=1; x<=n; x++){
for(ll y=1; y<=m; y++){
if(calc(U+n-x,L+m-y,D+n-x,R+m-y)==val-k) ans++;
}
}
printf("%lld\n",ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5868kb
input:
3 4 5 3 ULDDRR 4 5 0 UUUUUUU 4 5 10 UUUUUUU
output:
2 20 0
result:
ok 3 number(s): "2 20 0"
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 6492kb
input:
1060 19 12 0 UDLDDUUUUDDDLLRDUDUURULUUUDRDUDRDRLRLRLULULLLDLDDRLUUUURUUUDDRLLRUUUDULURUULLRDRLRDDURDUUURRRLURLRUULRRUDURDLUUURDLURDDLUUURDDRLLURRDLRUDLRDRLLRRDRDDLDRURRRLUDULLLRUUDLRRURRDLLRRRDLLRDDDLRLRURURDDDL 11 1 0 UR 3 18 33 UDRLR 17 11 132 RLDRDLDRUU 6 10 13 UULUDDLRDLUUDLDD 1 15 0 D 6 20 50 D...
output:
228 11 0 0 0 15 0 240 15 0 0 0 14 18 20 0 1 0 0 0 0 0 0 7 0 28 0 0 0 0 0 9 0 0 320 0 0 0 0 0 0 0 0 0 0 0 0 22 0 0 0 11 6 0 2 48 28 8 0 0 6 0 10 0 0 0 0 44 0 0 0 0 0 30 0 0 105 10 0 17 0 66 0 11 28 0 0 0 0 0 0 90 0 0 0 7 48 0 0 0 0 30 7 0 3 0 0 45 0 34 0 0 0 0 0 0 68 0 27 48 10 3 225 0 0 0 0 11 0 90 ...
result:
wrong answer 3rd numbers differ - expected: '20', found: '0'