QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#471897#1273. It's All Squaresgrass8cow#WA 199ms5064kbC++171.1kb2024-07-11 11:10:022024-07-11 11:10:02

Judging History

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

  • [2024-07-11 11:10:02]
  • 评测
  • 测评结果:WA
  • 用时:199ms
  • 内存:5064kb
  • [2024-07-11 11:10:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,a[410][410],q;
int vis[200000],l[410],r[410];
char c[301000];
#define pb push_back
void sol(){
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
    for(int i=1;i<=n*m;i++)vis[i]=0;
    for(int i=1;i<=n;i++)l[i]=r[i]=-1;
    for(int oo=1,x,y;oo<=q;oo++){
        scanf("%d%d%s",&x,&y,c+1);int L=strlen(c+1);
        vector<int>X;
        for(int i=1;i<=L;i++){
            if(c[i]=='L'){
                if(l[x]==-1)l[x]=y,X.pb(x);else r[x]=y;
                x--;
            }
            if(c[i]=='R'){
                x++;
                if(l[x]==-1)l[x]=y,X.pb(x);else r[x]=y;
            }
            if(c[i]=='D')y--;
            if(c[i]=='U')y++;
        }
        int ans=0;
        for(int o:X){
            if(l[o]>r[o])swap(l[o],r[o]);
            for(int i=l[o]+1;i<=r[o];i++){
                if(vis[a[o][i]]!=oo)
                vis[a[o][i]]=oo,ans++;
            }
            l[o]=r[o]=-1;
        }
        printf("%d\n",ans);
    }
}
int main(){
    int T;scanf("%d",&T);while(T--)sol();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
3 3 2
1 2 3
1 1 2
7 8 9
0 0 RRRUUULLLDDD
0 0 RRUULLDD

output:

6
2

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 199ms
memory: 5064kb

input:

10
353 304 4000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

59
68
78
54
70
56
62
72
115
108
65
72
66
55
68
89
60
56
57
56
52
70
77
69
69
104
56
74
59
54
60
56
56
62
53
71
54
67
43
49
68
68
76
68
100
48
59
51
54
88
65
74
58
78
51
87
48
81
66
80
57
65
59
47
100
48
56
65
84
64
65
88
81
70
59
71
58
70
75
66
65
52
101
66
53
55
68
63
105
85
77
72
65
89
61
82
77
88...

result:

wrong answer 2nd lines differ - expected: '64', found: '68'