QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#588882 | #5414. Stop, Yesterday Please No More | rotcar07 | WA | 3ms | 4080kb | C++20 | 1.0kb | 2024-09-25 15:03:01 | 2024-09-25 15:03:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
int n,m,k;
int a[N][N];
int main(){
int t;cin>>t;
while(t--){
for(int i=0;i<=n;i++)
for(int j=0;j<=m;j++) a[i][j]=0;
cin>>n>>m>>k;
set<pair<int,int>> S;
int mxx=0,mxy=0,mnx=0,mny=0,x=0,y=0;
string s;cin>>s;S.insert(make_pair(x,y));
for(auto c:s){
if(c=='L') y--;
else if(c=='R')y++;
else if(c=='U') x--;
else x++;
S.insert(make_pair(x,y));
mxx=max(mxx,x),mnx=min(mnx,x);
mxy=max(mxy,y),mny=min(mny,y);
}
int L=mxx+1,U=mxy+1,R=n+mnx,D=m+mny,res=(R-L+1)*(D-U+1);
if(L>R||U>D){
if(!k) cout<<n*m<<'\n';
else cout<<"0\n";
continue;
}
auto add=[&](int xa,int ya){int xb=xa-L+R,yb=ya-U+D;
//cout<<xa<<' '<<xb<<' '<<ya<<' '<<yb<<'\n';
a[xa][ya]++,a[xb+1][yb+1]++,a[xb+1][ya]--,a[xa][yb+1]--;
};
for(auto [x,y]:S){
add(x-mnx+1,y-mny+1);
}
int d=res-k,ans=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) ans+=((a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1])==d);
cout<<ans<<'\n';
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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: 4080kb
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 20 0 18 15 18 240 15 0 0 12 9 18 10 13 5 8 54 8 2 2 0 9 0 76 16 13 1 7 9 9 17 5 320 11 6 1 0 0 12 0 7 0 0 9 0 22 30 51 15 2 6 4 13 48 28 8 56 22 0 10 8 4 3 10 18 44 0 15 18 0 4 30 14 18 105 10 14 17 0 66 10 11 28 16 40 16 12 11 48 90 14 0 121 3 48 30 17 11 0 30 9 8 8 11 16 15 9 62 0 25 0 8 0 ...
result:
wrong answer 4th numbers differ - expected: '99', found: '0'