QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725073#5414. Stop, Yesterday Please No MorehelloccclWA 5ms22376kbC++202.8kb2024-11-08 16:08:332024-11-08 16:08:33

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 16:08:33]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:22376kb
  • [2024-11-08 16:08:33]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'