QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#693025#5414. Stop, Yesterday Please No MoreUItace#WA 3ms4088kbC++201.8kb2024-10-31 15:23:452024-10-31 15:23:48

Judging History

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

  • [2024-10-31 15:23:48]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4088kb
  • [2024-10-31 15:23:45]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
#define int long long
#define endl '\n'
typedef pair<int, int> pii;
const int inf = 1e18;
const int N = 2e5 + 5;

map<char,pii> op;
void init(){
    op['U'] = {-1,0};
    op['L'] = {0,-1};
    op['D'] = {1,0};
    op['R'] = {0,1};
}

void solve() {
    int n,m,k;
    cin>>n>>m>>k;
    string s;cin>>s;

    int x = 1,y = 1,nn = n,mm = m;
    stack<char> xx,yy;

    for(auto ch:s){
        if(mm <= 0 || nn <= 0){
            if(k == 0)cout<<n*m<<endl;
            else cout<<0<<endl;
            return;
        }
        if(ch == 'U' || ch == 'D'){
            if(xx.empty() || xx.top() == ch){
                xx.push(ch);
                nn--;
                if(ch == 'U')x++;
            }else xx.pop();
        }else{
            if(yy.empty() || yy.top() == ch){
                yy.push(ch);
                mm--;
                if(ch == 'L')y++;
            }else yy.pop();
        }
    }

    vector<vector<int>> fl(n+5,vector<int> (m+5,0));
    vector<vector<int>> mp(n+5,vector<int> (m+5,0));

    fl[x][y] = 1;
    mp[x][y] ++;mp[x+nn][y+mm]++;
    mp[x+nn][y]--;mp[x][y+mm]--;

    for(auto ch:s){
        x += op[ch].first;y += op[ch].second;
        if(fl[x][y])continue;
        fl[x][y] = 1;
        mp[x][y] ++;mp[x+nn][y+mm]++;
        mp[x+nn][y]--;mp[x][y+mm]--;
    }
    if(k > nn*mm) {
        cout << 0 << endl;
        return;
    }
    int ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            mp[i][j] += (mp[i-1][j] + mp[i][j-1] - mp[i-1][j-1]);
            if(mp[i][j] == nn*mm-k)ans++;
        }
    }
    cout<<ans<<endl;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    init();
    while (_--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

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

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: 3ms
memory: 4088kb

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

result:

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