QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627150#5414. Stop, Yesterday Please No MorebhscerWA 5ms8108kbC++174.8kb2024-10-10 14:58:512024-10-10 14:58:52

Judging History

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

  • [2024-10-10 14:58:52]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:8108kb
  • [2024-10-10 14:58:51]
  • 提交

answer

//#pragma GCC optimize(2)
//#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>

#define FOR(i, j, k) for(int i = (j);i <= (k);i ++)
#define ROF(i, j, k) for(int i = (j);i >= (k);i --)
#define For(i, j, k) for(int i = (j);i < (k);i ++)
#define Rof(i, j, k) for(int i = (j);i > (k);i --)
#define ull unsigned long long
#define int long long
#define PII pair<int,int>
#define ULL unsigned long long
#define db double
#define x first
#define y second
#define sp(x) fixed << setprecision(x)
#define all(x) x.begin(), x.end()
#define unq_all(x) x.erase(unique(all(x)), x.end())
#define M(x) x %= mod, x += mod, x %= mod
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define Yes cout << "Yes\n"
#define No cout << "No\n"
#define ANS cout << ans << '\n'
#define de(p) cout << #p << ' ' << p << '\n'
#define END(i, n) (i == n ? '\n' : ' ')
#define double long double

#define RED cout << "\033[91m"
#define GREEN cout << "\033[92m"
#define YELLOW cout << "\033[93m"
#define BLUE cout << "\033[94m"
#define MAGENTA cout << "\033[95m"
#define CYAN cout << "\033[96m"
#define RESET cout << "\033[0m"

// 红色
#define DEBUG1(x)                     \
    RED;                              \
    cout << #x << " : " << x << endl; \
    RESET;

// 绿色
#define DEBUG2(x)                     \
    GREEN;                            \
    cout << #x << " : " << x << endl; \
    RESET;

// 蓝色
#define DEBUG3(x)                     \
    BLUE;                             \
    cout << #x << " : " << x << endl; \
    RESET;

// 品红
#define DEBUG4(x)                     \
    MAGENTA;                          \
    cout << #x << " : " << x << endl; \
    RESET;

// 青色
#define DEBUG5(x)                     \
    CYAN;                             \
    cout << #x << " : " << x << endl; \
    RESET;

// 黄色
#define DEBUG6(x)                     \
    YELLOW;                           \
    cout << #x << " : " << x << endl; \
    RESET;


using namespace std;


const int N = 2e3 + 20, M = 1e6 + 10, INF = 1e9, mod = 998244353;

int n, m, k;
int pre[N][N];
bool vis[N][N];

int get(int x1,int y1, int x2,int y2) {
    return pre[x2][y2] - pre[x1-1][y2] - pre[x2][y1-1] + pre[x1-1][y1-1];
}
void solve() 
{
    cin >> n >> m >> k;
    string s;
    cin >> s;
    int X = n,Y = m;
    int max_x = n,max_y = m,min_x = 0,min_y = 0;

    vis[X][Y] = 1;
    pre[X][Y] = 1;

    for(auto i : s)
    {
        if (i == 'D')
        {
            X ++;
            max_x ++,min_x ++;
        }
        if (i == 'L')
        {
            Y --;
            max_y --,min_y --;
        }
        if (i == 'U')
        {
            X --;
            max_x --,min_x --;
        }
        if (i == 'R')
        {
            Y ++;
            max_y ++,min_y ++;
        }

        max_x = min(max_x, n);min_x = min(min_x, n);
        max_x = max(max_x,0ll);min_x = max(min_x, 0ll);
        max_y = min(max_y, m);min_y = min(min_y, m);
        max_y = max(max_y, 0ll);min_y = max(min_y, 0ll);

        if (X >= 0 && Y  >= 0 && X <= 2 * n && Y <= 2 * m && !vis[X][Y])
        {
            vis[X][Y] = 1;
            pre[X][Y] = 1;
        }
    }

//    FOR(i,1,2 * n)
//        FOR(j,1,2 * m)
//        {
//            cout << pre[i][j] << END(j,2 * m);
//        }
    FOR(i,1,2 * n)
    {
        FOR(j,1,2 * m)
        {
            pre[i][j] += pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1];
        }
    }
    if (min_x == max_x || min_y == max_y)
    {
        int ans = 0;
        if (k == 0)
        {
            ans = n * m;
        }
        ANS;
    }
    else
    {
        int ans = 0;
        min_x ++;min_y ++;
//        DEBUG5(min_x)
//        DEBUG5(max_x)
//        DEBUG5(min_y)
//        DEBUG5(max_y)


        int lenx = max_x - min_x + 1,leny = max_y - min_y + 1;

//        DEBUG3(lenx)
//        DEBUG3(leny)
        X = X - n + min_x;Y = Y - m + min_y;

//        DEBUG4(X)
//        DEBUG4(Y)
        FOR(x,X,X + n - 1)
            FOR(y,Y,Y + m - 1)
            {
//            cout << x << ' ' << y << ' ' << x + lenx - 1 << ' ' << y + leny - 1 << ' ' << get(x,y,x + lenx - 1,y + leny - 1) << '\n';
                if (get(x,y,x + lenx - 1,y + leny - 1) == lenx * leny - k) ans ++;
            }
        ANS;
    }


    FOR(i,1,2 * n)
    {
        FOR(j, 1, 2 * m)
        {
            vis[i][j] = pre[i][j] = 0;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    auto t = clock();
    int T = 1;
    cin >> T;

    while (T--) {
        solve();
    }
    auto tt = clock();

//    cout << "Time: " << 1000.0 * (tt - t) / CLOCKS_PER_SEC << "ms" << endl;

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5564kb

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: 5ms
memory: 8108kb

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
2
99
7
15
34
240
7
0
0
2
14
18
13
1
18
17
108
4
1
1
0
31
1
17
12
16
0
1
9
9
2
5
320
1
5
3
0
0
8
0
0
0
0
6
0
22
36
51
10
1
6
1
1
48
28
8
63
11
49
0
4
2
108
9
9
44
0
1
1
0
4
30
2
99
105
4
0
17
0
66
2
11
28
52
19
56
33
9
56
90
14
0
121
3
48
13
15
14
0
30
10
5
1
7
16
45
19
17
2
19
0
25
0
23
0
20
...

result:

wrong answer 3rd numbers differ - expected: '20', found: '2'