QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401375#5414. Stop, Yesterday Please No Morexjt05WA 328ms11488kbC++231.7kb2024-04-28 16:25:012024-04-28 16:25:03

Judging History

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

  • [2024-04-28 16:25:03]
  • 评测
  • 测评结果:WA
  • 用时:328ms
  • 内存:11488kb
  • [2024-04-28 16:25:01]
  • 提交

answer

#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
const int maxn = 1e3+10;

int t,n,m,k;
int a[maxn][maxn];
int vis[maxn][maxn];

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while(t--){
    	memset(a,0,sizeof(a));
    	memset(vis,0,sizeof(vis));
    	string s;
    	cin >> n >> m >> k;
		cin >> s;
		int tu=1,td=n,tl=1,tr=m;
		int u=1,d=n,l=1,r=m;
		for(int i=0; i<s.length(); i++){
			switch(s[i]){
				case 'U':
					tu++,td++;
					break;
				case 'D':
					tu--,td--;
					break;
				case 'L':
					tl++,tr++;
					break;
				case 'R':
					tl--,tr--;
					break;
			}
			u=max(u,tu);
			d=min(d,td);
			l=max(l,tl);
			r=min(r,tr);
		}
		
		if(u>d || l>r){
			if(k!=0) cout << 0 << endl;
			else cout << n*m << endl;
			continue;
		}
		if((d-u+1)*(r-l+1)<k){
			cout << 0 << endl;
			continue;
		}
		k=(d-u+1)*(r-l+1)-k;
		tu=u,td=d,tl=l,tr=r;
		a[u][l]++,a[d+1][l]--,a[u][r+1]--,a[d+1][r+1]++;
		for(int i=0; i<s.length(); i++){
			switch(s[i]){
				case 'U':
					tu--,td--;
					break;
				case 'D':
					tu++,td++;
					break;
				case 'L':
					tl--,tr--;
					break;
				case 'R':
					tl++,tr++;
					break;
			}
			if(vis[tu][tl]){
				continue;
			}
			else{
				vis[tu][tl]=1;
				a[tu][tl]++,a[td+1][tl]--,a[tu][tr+1]--,a[td+1][tr+1]++;
			}
		}
		for(int i=1; i<=n; i++){
			for(int j=1; j<=m; j++){
				a[i][j]+=(a[i-1][j]+a[i][j-1]-a[i-1][j-1]);
			}
		}
		int ans=0;
		for(int i=1; i<=n; i++){
			for(int j=1; j<=m; j++){
				if(a[i][j]==k){
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

详细

Test #1:

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

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: 328ms
memory: 11488kb

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

result:

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