QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499498#6723. Grid with ArrowsbuzhijingdiWA 42ms5520kbC++142.0kb2024-07-31 14:58:582024-07-31 14:59:05

Judging History

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

  • [2024-07-31 14:59:05]
  • 评测
  • 测评结果:WA
  • 用时:42ms
  • 内存:5520kb
  • [2024-07-31 14:58:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 9;
const int M = 1e3 + 9;
const int mod = 1e9 + 7;
#define eps 1e-5
#define inf 2e18

int a[N];
int vis[N];
int n,m;

void solve()
{
    cin>>n>>m;
   // for(int i=1;i<=n;++i) a[i]=0;
    char s[n + 5][m + 5];
    int p[n + 5][m + 5];
    int cnt=0,sum=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)   cin>>s[i][j];
        

    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j) 
        {
            cin>>p[i][j];
            if(s[i][j]=='u')
            {
                if(i - p[i][j] >= 1) sum++;
                if(i - p[i][j] >= 1 &&  s[i - p[i][j]][j] != 'u' && s[i - p[i][j]][j]!='d')
                {
                    if(!vis[i - p[i][j]]) cnt++;
                    vis[i - p[i][j]]++;
                }
            }
            else if(s[i][j]=='d')
            {
                if(i + p[i][j] <= n) sum++;
                if(i + p[i][j] <= n &&  s[i + p[i][j]][j] != 'u' && s[i + p[i][j]][j]!='d')
                {
                    if(!vis[i + p[i][j]]) cnt++;
                    vis[i + p[i][j]]++;
                }
            }
        }
    if(cnt != n)
    {
        cout<<"No"<<'\n';
        return ;
    } 
   // cout<<sum<<'\n';
    bitset<M> st; 
    for(int i=1;i<=n;++i)
    {
        st.reset();
        for(int j=1;j<=m;++j)
        {
            if(s[i][j]=='r' && p[i][j] + j <=m && !st[p[i][j] + j])
            {
                st[p[i][j] + j]=1;
                sum++;
            }
            else if(s[i][j]=='l' && j  - p[i][j] >= 1 && !st[j  - p[i][j] ])
            {
                st[j  - p[i][j] ]=1;
                sum++;
            }
        }
    }

    if(sum >= n*m - 1) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;  cin>>_;
    while (_--) solve();
    return 0;
}
/*
3 3
rrd
udl
url
1 1 1
1 1 1
1 1 2
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3572kb

input:

2
2 3
rdd
url
2 1 1
1 1 2
2 2
rr
rr
1 1
1 1

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #2:

score: -100
Wrong Answer
time: 42ms
memory: 5520kb

input:

1109
5 8
rddddldl
drruludl
rrldrurd
urrrlluu
uurrulrl
4 4 1 2 4 3 1 6
1 3 5 1 1 1 3 6
2 4 1 1 2 1 1 1
2 3 4 2 4 3 3 3
4 1 1 2 2 5 1 5
7 9
rdrddrdll
urrdruldl
ruullrulu
drrlrlddl
rrrdddlll
ruulururl
ruurrlluu
7 1 1 1 2 1 2 3 6
1 7 3 1 3 1 2 1 8
2 2 1 2 4 3 1 2 2
2 2 4 1 1 5 3 3 1
3 4 6 1 2 1 2 7 7
6 ...

output:

Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No...

result:

wrong answer expected YES, found NO [5th token]