QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#725073 | #5414. Stop, Yesterday Please No More | hellocccl | WA | 5ms | 22376kb | C++20 | 2.8kb | 2024-11-08 16:08:33 | 2024-11-08 16:08:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int mp[2005][2005];
int n,m,k;
int maxu,maxd;
int maxl,maxr;
int sum[2005][2005];
void solve()
{
maxu= 0;maxd=0;
maxl= 0;maxr=0;
cin >> n >> m >> k;
char s[1000005];
cin >> s;
int len = strlen(s);
for(int i = 0;i<=2*m+1;i++)
{
for(int j = 0;j<=2*n+1;j++)
{
mp[i][j] = 1;
}
}
int tempup = 0;
int templr = 0;
for(int i = 0;i<len;i++)
{
if(s[i]=='U')
{
tempup ++;
maxu = max(maxu,tempup);
maxd = min(maxd,tempup);
}
if(s[i]=='D')
{
tempup --;
maxu = max(maxu,tempup);
maxd = min(maxd,tempup);
}
if(s[i]=='L')
{
templr --;
maxl = min(templr,maxl);
maxr = max(templr,maxd);
}
if(s[i]=='R')
{
templr --;
maxl = min(templr,maxl);
maxr = max(templr,maxd);
}
}
//maxl,maxr,maxd,maxu;
int wide ;int high;
wide = m - maxr - abs(maxl);
high = n - maxu - abs(maxd);
if(wide <=0||high <=0)
{
if(k == 0)
{
cout << n * m <<'\n';
return;
}
}
//cout << high <<' ' <<wide<< '\n';
int x = m ;
int y = n ;
mp[x][y] = 0;
for(int i = 0;i<len;i++)
{
if(s[i]=='U')
{
y --;
}
if(s[i]=='D')
{
y++;
}
if(s[i]=='L')
{
x++;
}
if(s[i]=='R')
{
x--;
}
mp[x][y] = 0;
}
for(int i = 1;i<=2004;i++)
{
for(int j = 1;j<=2004;j++)
{
sum[i][j] = sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+mp[i][j];
}
}
//cout << sum[2][2]<<'\n';
int ans = 0;
for(int i = 1;i<=m ;i++)
{
for(int j = 1;j<=n;j++)
{
int temp =0;
/*cout << sum[i + wide + abs(maxl)-1][j+high + abs(maxu) -1]<<' '
<< sum[i + abs(maxl) - 1][j+high + abs(maxu) -1] <<' '<< sum[j + abs(maxu)-1][i + wide + abs(maxl)-1] <<' '<< sum[i + abs(maxl) - 1][j + abs(maxu)-1] <<'\n';*/
temp = sum[i + wide + abs(maxl)-1][j+high + abs(maxu) -1] -sum[i + abs(maxl) - 1][j+high + abs(maxu) -1] - sum[j + abs(maxu)-1][i + wide + abs(maxl)-1] + sum[i + abs(maxl) - 1][j + abs(maxu)-1];
if(temp == k)
{
ans ++;
}
//cout << temp << '\n';
}
}
cout << ans << '\n';
}
int main()
{
int _;
cin >> _;
while (_--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 22376kb
input:
3 4 5 3 ULDDRR 4 5 0 UUUUUUU 4 5 10 UUUUUUU
output:
1 20 0
result:
wrong answer 1st numbers differ - expected: '2', found: '1'