QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499496#6723. Grid with ArrowsInk_baiRE 3ms10708kbC++202.2kb2024-07-31 14:58:392024-07-31 14:58:40

Judging History

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

  • [2024-07-31 14:58:40]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:10708kb
  • [2024-07-31 14:58:39]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

vector<int> a(1000005), b(1000005);
char s[1000005];

int updiv(int a, int b)
{
    return a / b + (a % b ? 1 : 0);
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    a.clear();
    b.clear();
    a.resize(1000005);
    b.resize(1000005);
    int T;
    cin >> T;
    while (T--)
    {
        int n, m;
        cin >> n >> m;
        for (int i = 1; i <= n * m; i++)
        {
            char c;
            cin >> c;
            s[i] = c;
        }
        for(int i = 1; i <= n * m; i++)
        {
            // cout << i << ' ' << s[i] << endl;
            int x;
            cin >> x;
            if(s[i] == 'u'&& i - m * x >= 1)
            {
                a[i - m * x]++;
                b[i]++;
            }
            else if(s[i] == 'd'&& i + m * x <= n * m)
            {
                a[i + m * x]++;
                b[i]++;
            }
            else if(s[i] == 'l'&& updiv(i, m) == updiv(i - x, m))
            {
                a[i - x]++;
                b[i]++;
            }
            else if(s[i] == 'r'&& updiv(i, m) == updiv(i + x, m))
            {
                a[i + x]++;
                b[i]++;
            }
        }
        int u = 0, v = 0;
        bool flag = false;
        for(int i = 1; i <= n * m; i++)
        {
            if(flag||u > 1||v > 1)
            {
                flag = true;
                break;
            }
            else if(a[i] == b[i]&& b[i] == 0)
            {
                flag = true;
                break;
            }
            else if(a[i] - b[i] == 1)
            {
                u++;
            }
            else if(b[i] - a[i] == 1)
            {
                v++;
            }
            else if(a[i] == b[i])
            {
                continue;
            }
            else
            {
                flag = true;
            }
        }
        if(u > 1||v > 1)
        {
            flag = true;
        }
        if(flag)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 10708kb

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
Runtime Error

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
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
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
N...

result: