QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#704157#166. Shifting a MatrixTheZoneAC ✓46ms10468kbC++206.0kb2024-11-02 19:25:412024-11-02 19:25:43

Judging History

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

  • [2024-11-02 19:25:43]
  • 评测
  • 测评结果:AC
  • 用时:46ms
  • 内存:10468kb
  • [2024-11-02 19:25:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=1e4+1e3+7;

int n;

using perm=vector<int>;

perm operator *(const perm &a,const perm &b)
{
    perm c(n);
    for(int i=0;i<n;i++)
        c[i]=a[b[i]];
    return c;
}

perm operator ^(const perm &a,int b)
{
    perm vis(n),c(n);
    for(int i=0;i<n;i++)
    {
        if(vis[i])
            continue;
        int x=i;
        vector<int> cir;
        while(!vis[x])
            cir.push_back(x),vis[x]=1,x=a[x];
        for(int j=0;j<cir.size();j++)
            c[cir[j]]=cir[(j+b)%cir.size()];
    }
    return c;
}

int m;

int to[N];

string s;

int on;

perm calc(char opt,int x)
{
    --x;
    perm ret(n);
    iota(ret.begin(),ret.end(),0);
    if(opt=='R'||opt=='L')
    {
        vector<int> vp;
        for(int i=0;i<on;i++)
            vp.push_back(ret[x*on+i]);
        int sft=opt=='L'?1:n-1;
        for(int i=0;i<on;i++)
            ret[vp[i]]=vp[(i+sft)%on];
    }
    else
    {
        vector<int> vp;
        for(int i=0;i<on;i++)
            vp.push_back(ret[i*on+x]);
        int sft=opt=='U'?1:n-1;
        for(int i=0;i<on;i++)
            ret[vp[i]]=vp[(i+sft)%on];
    }
    return ret;
}

perm solve(int l,int r)
{
    perm ret;
    if(s[l]=='(')
    {
        int L=l+1,R=to[l]-1;
        ret=solve(L,R);
        int k=to[l]+1;
        string t;
        while(k<=r&&isdigit(s[k]))
            t+=s[k],k++;
        ret=ret^stoi(t);
        if(k<=r)
            ret=ret*solve(k,r);
    }
    else
    {
        char opt=s[l];
        int k=l+1;
        string t;
        while(k<=r&&isdigit(s[k]))
            t+=s[k],k++;
        ret=calc(opt,stoi(t));
        if(k<=r)
            ret=ret*solve(k,r);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    on=n;
    cin>>s;
    n=n*n;
    vector<int> st;
    for(int i=0;i<m;i++)
    {
        if(s[i]!='('&&s[i]!=')')
            continue;
        if(s[i]=='(')
            st.push_back(i);
        else
        {
            to[st.back()]=i;
            st.pop_back();
        }
    }    
    perm ans=solve(0,m-1);
    int z=on;
    for(int i=0;i<z;i++)
        for(int j=0;j<z;j++)
            cout<<ans[i*z+j]+1<<" \n"[j+1==z];
}
/*#include<bits/stdc++.h>
using namespace std;

const int N=1e4+1e3+7;

int n;

using perm=vector<int>;

perm operator *(const perm &a,const perm &b)
{
    perm c(n);
    for(int i=0;i<n;i++)
        c[i]=a[b[i]];
    return c;
}

perm operator ^(const perm &a,int b)
{
    perm vis(n),c(n);
    for(int i=0;i<n;i++)
    {
        if(vis[i])
            continue;
        int x=i;
        vector<int> cir;
        while(!vis[x])
            cir.push_back(x),vis[x]=1,x=a[x];
        for(int j=0;j<cir.size();j++)
            c[cir[j]]=cir[(j+b)%cir.size()];
    }
    return c;
}

int m;

int to[N];

string s;

int on;

perm calc(char opt,int x)
{
    --x;
    perm ret(n);
    iota(ret.begin(),ret.end(),0);
    if(opt=='R'||opt=='L')
    {
        vector<int> vp;
        for(int i=0;i<on;i++)
            vp.push_back(ret[x*on+i]);
        int sft=opt=='L'?1:n-1;
        for(int i=0;i<on;i++)
            ret[vp[i]]=vp[(i+sft)%on];
    }
    else
    {
        vector<int> vp;
        for(int i=0;i<on;i++)
            vp.push_back(ret[i*on+x]);
        int sft=opt=='U'?1:n-1;
        for(int i=0;i<on;i++)
            ret[vp[i]]=vp[(i+sft)%on];
    }
    return ret;
}

perm solve(int l,int r)
{
    perm ret;
    if(s[l]=='(')
    {
        int L=l+1,R=to[l]-1;
        ret=solve(L,R);
        int k=to[l]+1;
        string t;
        while(k<=r&&isdigit(s[k]))
            t+=s[k],k++;
        ret=ret^stoi(t);
        if(k<=r)
            ret=ret*solve(k,r);
    }
    else
    {
        char opt=s[l];
        int k=l+1;
        string t;
        while(k<=r&&isdigit(s[k]))
            t+=s[k],k++;























































































































































































































































































































































































































































































































































































































































































































































vyng
        ret=calc(opt,stoi(t));
        if(k<=r)
            ret=ret*solve(k,r);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    on=n;
    cin>>s;
    n=n*n;
    vector<int> st;
    for(int i=0;i<m;i++)
    {
        if(s[i]!='('&&s[i]!=')')
            continue;
        if(s[i]=='(')
            st.push_back(i);
        else
        {
            to[st.back()]=i;
            st.pop_back();
        }
    }    
    perm ans=solve(0,m-1);
    int z=on;
    for(int i=0;i<z;i++)
        for(int j=0;j<z;j++)
            cout<<ans[i*z+j]+1<<" \n"[j+1==z];
}*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2
R1

output:

3 1 2
4 5 6
7 8 9

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

3 7
(U2)300

output:

1 2 3
4 5 6
7 8 9

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

3 7
(R1D1)3

output:

3 4 7
1 5 6
2 8 9

result:

ok 3 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

2 20
D2(((L2(D1)4)5)4R2)5

output:

1 4
2 3

result:

ok 2 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

3 18
D2R3(R1(D1U1R1)1)2

output:

3 1 8
4 2 6
9 7 5

result:

ok 3 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

2 20
U1U1L1L1L2R2R1D2D2D1

output:

3 1
2 4

result:

ok 2 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

3 19
(U1D2D3)2D2L3U2L2D2

output:

7 2 6
3 5 1
8 9 4

result:

ok 3 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

2 18
((L2L2D2)4L1L2U2)4

output:

1 2
3 4

result:

ok 2 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

5 100
L5U4D3L5R3L3L1D3L4R2(R1R4L5D4U2U2(U3U3L3D2(D5U4D5L4(D1((R1R1U4D3R1D1U5)52)97)67)90)53L3D4U1)73L1D1D2

output:

1 21 8 13 12
9 24 20 10 23
2 17 4 6 3
19 22 7 11 16
5 15 14 25 18

result:

ok 5 lines

Test #10:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

7 100
((((U4R4((L5D5R3(U2(L4U4D2U6)64L1(R2L1)96((D5D7D1)57)27R4L4L5L2)89R6L2)25R3)78U1D6)46U7U4U5)30)66)50

output:

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

result:

ok 7 lines

Test #11:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

9 99
R9U6(R1U5U5((U3R5(R3D5(U9U5(R8U9R1R7L3L7(R7L9U2)32U1R3U7)31R4D6)3L7(D2)22L2)23U6)48U4)45L1D1U3)80D7

output:

38 2 74 57 5 4 78 8 9
28 11 56 51 61 76 7 17 50
37 20 19 30 23 33 16 26 27
48 21 43 40 14 44 25 35 36
70 68 24 46 41 77 34 3 45
69 47 12 49 13 60 22 53 54
62 29 15 58 55 10 42 59 18
72 65 52 66 31 32 63 71 81
64 73 67 75 39 6 1 79 80

result:

ok 9 lines

Test #12:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

6 98
L2L2R5(U2(R1D2R3D6U6D2)55R6(D6(U2R5D5D6R6L1R6R5(U6D4D2L6U2L3)34L4)30L6R2R1D3L1R5R2)76R3D3D4R5)44R5

output:

8 14 13 9 5 6
12 35 4 21 18 27
28 23 16 34 17 15
19 24 11 22 29 30
26 2 20 36 1 33
31 10 25 7 3 32

result:

ok 6 lines

Test #13:

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

input:

6 99
L5(D1R6(U3(D2(D6(L6((U1R5)76)44D2L4R2D4D1(U6R5)12)52R4(U5D5D1(R1U3U3)31)44R3R3L1U6R1)49D1D5)9)58)43

output:

8 2 31 3 29 5
15 32 35 25 16 7
14 27 21 11 12 4
22 10 17 13 36 24
23 33 6 19 20 9
28 30 1 18 34 26

result:

ok 6 lines

Test #14:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

5 99
L4U4(R2L1U3L3R1U3R1L5L5((U3R1U5(L5D3D4)229859374L2L4R5D1R3)4303304)40898021)732540237R2L3R4U5U3R4L1

output:

16 21 24 14 1
10 8 17 15 12
11 13 23 7 9
3 2 20 18 19
6 22 25 4 5

result:

ok 5 lines

Test #15:

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

input:

8 90
L8D1(U7L3L8L2R2L2(D5D6D6D5R3L7R1L5R4L6U4R6R8U3L5D6D5U2)943326035D7)905483249D6R7D7L6D3L8L6

output:

11 34 43 23 3 22 14 10
4 40 59 31 28 30 19 56
24 46 7 51 52 64 60 21
45 41 25 49 9 36 53 47
8 12 62 17 18 61 32 16
57 29 15 63 6 48 33 39
35 27 44 13 42 5 54 55
58 26 1 20 2 50 38 37

result:

ok 8 lines

Test #16:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

9 98
L8((L3(R5R3L3R7)18237661R1R1D1U2R1L3)113932439U2D9R7R8L1U2L4R9U2L3(R7R8L9L4U5)684821085)70323196L7

output:

4 37 33 23 2 9 11 60 18
59 75 12 13 47 15 16 17 68
34 43 45 24 80 27 10 62 35
26 46 61 22 50 64 76 41 3
54 30 5 36 38 44 7 65 74
19 58 48 49 56 51 52 53 21
6 55 28 66 57 32 40 71 31
79 73 63 20 25 39 1 70 69
81 77 42 14 67 72 29 8 78

result:

ok 9 lines

Test #17:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

7 100
R1U1U2L4U5(R6D6R2U1D1U2U1R7L4(U1D6D1(U5U2L7L7R2R7L1D1)104487086R5)179646336(D3)289104036)761708102D2

output:

13 27 26 3 12 29 6
22 15 34 10 11 30 5
31 46 49 18 40 32 21
39 45 44 33 9 1 38
16 17 2 7 43 42 47
24 23 28 25 37 4 41
20 35 14 8 19 36 48

result:

ok 7 lines

Test #18:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

9 100
(L7D6U1D9D6L9((U8R5(R5L8)468040103U9D8R5D1U9D6R2U5D5D7(R4R5)152327505)816004889D6)605641470)28471714

output:

19 2 3 4 5 6 51 8 9
38 39 31 45 54 46 69 24 43
70 20 21 22 23 66 41 26 78
18 29 63 58 32 10 68 35 42
11 60 59 52 25 34 67 28 57
17 47 48 49 50 73 40 53 56
15 16 7 80 30 27 12 1 74
64 37 61 77 76 65 36 71 44
33 72 55 14 13 75 79 62 81

result:

ok 9 lines

Test #19:

score: 0
Accepted
time: 3ms
memory: 4380kb

input:

56 998
L16R25(R14D21U30R9(U43(L1R30L5(D2U14(U56(U18(R42D9D3D13U29D45L51(U15D54((((U53U38L55D1U54L38R46L5R3((D49R55(U16((R44U52U11(R42L46U18L37D18R3(R6D20D8U45U47)374378779)353575447)164645749D18R53(R15(U4D43((((D39L8D51D16L50R43R49L56)809218101L47(R7D20(L10L54R40(U24L18)62146950(D28R28D21L12(D11D29D...

output:

1183 477 813 23 2899 1803 1005 2146 2080 2299 2575 167 2391 589 2403 536 592 187 1329 1720 2197 1344 1657 2723 760 2488 1736 3097 2959 2521 601 247 840 1001 1885 1901 289 551 2489 383 1150 942 1192 593 655 2857 2565 1040 2725 1887 2537 674 728 579 1209 2937
1493 1649 1156 1346 2791 1019 880 233 2990...

result:

ok 56 lines

Test #20:

score: 0
Accepted
time: 3ms
memory: 4120kb

input:

53 1000
D40(U51D53(D21U18((R8(D23D21((R47(U8(U25D32D37((R11L20(D52D22R39R8(L15D19)230117074((U33R46)974941979L20(L42(U34R44R35D44D31((D35D17R18(R12D15D21D33)631880494D12L18)114306931R19L21(U5R23L42L7(R33R48L41D49D30((U42R43R32(U1D31D35(R11U33L31R53R43D44(D50R26D34(U21U5U14R18)567786864((U34)32612257...

output:

1 346 457 1406 1887 6 2470 1358 93 1392 1713 13 2473 2646 1072 1979 2720 286 1929 2740 424 719 27 2253 2444 521 2435 2796 864 2631 1739 2037 1136 2433 375 1276 2008 1512 309 2697 1334 1188 850 289 1089 2431 2522 1902 111 835 2505 466 1648
2178 426 565 2423 58 2430 2126 791 1923 63 886 1581 1232 970 ...

result:

ok 53 lines

Test #21:

score: 0
Accepted
time: 2ms
memory: 4284kb

input:

59 996
U3(L44U25R31D2L10L32(U37(((U55D53R42L48U52R31(((L53U9R11)901267958(D20D33(((R16L51D28L7R31D34D39U33R11(D1D43U18D19L3((L45R7(U53(D58D54D19U4)44925351R27(((R18D16)327104053L4R34(D11U7D23L39R19)872488987L5L5((U20(R5R11L19U36U4U52D41)443825863(R27R33R20D44(R52U29U12L54(U7U43(U31(U4(U36(R41)147248...

output:

1579 1422 62 427 5 2560 7 3394 3332 69 11 134 1227 3103 1090 373 17 2989 2316 3135 2986 185 23 2025 3322 26 27 2124 2868 30 2187 32 339 692 35 405 147 2429 39 40 257 3247 1664 3172 2185 46 2808 48 49 50 1903 3390 1106 292 3336 56 57 267 2843
1567 636 121 1720 64 978 2541 67 3387 3068 603 3167 72 117...

result:

ok 59 lines

Test #22:

score: 0
Accepted
time: 8ms
memory: 5624kb

input:

90 998
L78((L56L55U42D50D65(D47L41U8(((R70(R80R26(D3(L8(U62D81U56(R2(R37L49D83(L75(U47D34)174297544(L12R2U11D51R45R61(((U85D53(R49R77R19R86(D5(L39R12R23)55930239D89R15(L56(D59L39L40D54U41D84R10L85(D15((L3U8(D78U67U14D84L71U5)829432575)465223495D38)674184914((D53D45)931473517D87D60(R41D78L34)89348077...

output:

2550 3275 440 6280 7980 4853 4413 2177 443 789 7070 4954 3873 7518 7394 312 7938 1827 1530 2576 3956 1526 5599 7121 357 4290 1443 905 4507 1426 3117 2943 4598 5063 1036 149 3058 6441 6376 4668 5967 5625 8053 1847 3044 174 1965 7844 7847 7101 8004 400 3615 4844 3151 175 5299 1026 5754 1212 2051 1607 ...

result:

ok 90 lines

Test #23:

score: 0
Accepted
time: 9ms
memory: 5576kb

input:

93 1000
L8(U58((D62U23((L56(U50R10U27(D17D14R92L27(((R79R33D42(U18D80L69U69U41L40R30U25)154920149L70U58U34D64L43(R47(D78(R66(L27D89L28D89(U29R69((U28((D32L66L82D53U28D3(U69D36D78)356955013R12(U87D68D70)664050274D9((D8U27)218567730(R69R66(L72U67D47(((R72L46U55L32D25D74(U33D75L40)325161903(R53R69R21)3...

output:

1 2 1820 2659 5 6 7 3038 4724 10 1376 12 13 1402 15 7941 7248 3844 1355 20 21 5948 7054 24 6357 26 7884 191 1863 30 31 5839 4710 8474 35 2194 7059 38 2031 5062 2219 36 6826 44 5381 46 4316 48 49 2283 5795 52 1576 54 287 56 57 3641 5223 60 61 5247 1349 1686 4698 66 8452 7596 2451 2447 71 72 73 6938 6...

result:

ok 93 lines

Test #24:

score: 0
Accepted
time: 11ms
memory: 6588kb

input:

100 999
(R33U28R10L78D13L2D87L46R51((R57L37(D16((U28L4U19(R17(L16L32D7(D15L65L61(D82D94L5U79U27(L52((R28L31(((R39L42U22L85U39U45(((U37D5(R37U50R47L36R46D63)74281711D46D55)269020473D67U50)533258424L3L2R33U34((L41((U80L41L94(U39(L52(D24D20(L38)753032978U53(U22)711172194)215409254((U59R82L67L17)2641754...

output:

1 3618 3848 4 5 6 8666 8 7182 2564 624 12 4646 8679 7419 1601 3624 5346 2366 8934 21 5505 23 3918 8986 6967 5121 8422 5451 30 31 8955 33 6695 35 36 4820 4389 39 5768 5675 848 43 44 8471 500 937 6580 9832 331 3762 1639 4750 54 55 56 4198 58 7549 60 61 62 4614 64 65 3076 4986 9859 69 3632 71 72 73 74 ...

result:

ok 100 lines

Test #25:

score: 0
Accepted
time: 5ms
memory: 4736kb

input:

71 1000
L44(D61L54D1R36(R12U4U1(R32(U21U30R59U46U21R29(R6D36(D23D5U3U42R66U31((R12((U12(((((R63L8(D49R42D35(U65D66D13((U41U26(R26R33D56U59(D30((D24U40L68(D30L53D22R48((L44L7D46L1)275264089U48L4L67(D56)598604155R11L47((U32(((D8D49D30(U54U5R63R8D10D33U27)651567748(((U46((L34)522223357U60)715069427U17)...

output:

3367 523 372 2261 1145 2904 4068 2543 992 10 1231 12 1747 14 603 413 3373 18 19 20 1463 22 3160 181 105 2526 27 301 2227 1282 31 2230 2719 2319 35 1396 37 1915 1947 1595 41 42 1527 44 45 3233 525 48 4687 50 64 52 53 4578 55 572 1728 58 4125 3684 4259 1762 996 2883 65 4697 67 2761 2979 3916 4601
4438...

result:

ok 71 lines

Test #26:

score: 0
Accepted
time: 4ms
memory: 4616kb

input:

64 996
L9R10((R62R2R12D35(U21U13D26(D34R22U11R5R57(L35L23R58((U39(((L36R25D56((R2D13U63R19(R8D33R57(R20L61((R7(U64(R6D20(D6D24U30R9U62U51)346930117U47D29((U14D53L56L61U52R21D61U52(R64(U34L46)653636482R1R63R31R10(R52(R39D44D5R48D56R44L12D41R42D9(U32U57U57D47U7R25R38)9927850R62L31)167623949U22(D6L16U3...

output:

3324 532 1974 1600 882 3827 2607 1796 3301 657 11 158 2935 412 2818 3277 2164 2074 3288 1432 2701 3386 741 443 447 387 1342 702 3067 573 436 3234 2069 284 1322 2996 1869 2844 2462 3935 341 2295 3208 1262 3676 3203 1269 18 2160 2813 3434 1977 2660 1916 3446 3426 1069 2544 3774 3069 522 798 526 3010
5...

result:

ok 64 lines

Test #27:

score: 0
Accepted
time: 3ms
memory: 4220kb

input:

56 1000
U24(R18D45U34(((R24(U4D21(D44D44(L5U19R24U27((U31R6R20D17L20U45R32R14(((R8U37U7D49R45U30U18D22L28((D25U26R4D36R51R10(L15L7L28U39R12R32)424995366R51(L41D13R14U50(L25R7(D1R40(((L45(R42((D52D21U19L30((U11L14R13U27(U19U47L35U13D44L22)220282488D11L55)33158556)560527909U28R32R22D26)268018628)24447...

output:

1867 2 3075 690 826 210 1141 8 9 481 1718 12 1571 2161 15 1568 2887 2505 647 153 2100 1913 1260 80 2407 2164 207 2554 49 1484 3049 1684 1058 1434 2835 916 1237 1757 1085 40 3012 1917 43 391 3007 1406 2676 48 1313 2714 51 2099 2848 2118 333 56
1491 58 339 2596 1139 1934 737 64 65 1901 2258 68 1211 20...

result:

ok 56 lines

Test #28:

score: 0
Accepted
time: 0ms
memory: 5228kb

input:

81 991
R52((D66R8D46(R3U23(D8L3(U7(R38(R80R17U74(L48((D36D39L79R81U12U42L74U65D72L76(R16D23U79R55D25U51U4R32(D54D42U45((L55(D1D69L52R43U77)360298809)347779032R47U71L55L69(U43D22D75L76(U54(R8(D45((R48(U15)722792973R61)282446728U32)242763492U36(((U53R16R71R3R75U29U65U11(L73R32U81(U21U20R48R66U74U43(U6...

output:

4741 2841 4748 5789 3781 3250 1591 3784 1487 2784 11 3632 3656 3286 2662 2124 3698 2343 1776 371 3111 5892 6323 6004 25 3232 1539 3446 4563 4638 6534 2687 5973 2347 1053 2921 3699 3680 3312 4338 41 6554 5946 5337 592 2790 5646 5635 6185 1301 51 6504 996 2793 4218 5312 57 5884 220 4440 4716 62 148 17...

result:

ok 81 lines

Test #29:

score: 0
Accepted
time: 5ms
memory: 4048kb

input:

60 996
((((((L54((((((((((((((((((((U58(((((R29(((((((((U37((((((U6L25)596313456)901188938((((((((((((((((((((((((L24)74992039)762172868)105882139)210422314)873100620)86704467)228592452)76124957)264130528)238832856(R33)559204219)378696914)274013441)187544662)274196328)735052829)283446013)345918240)8...

output:

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 99 100 101 102 ...

result:

ok 60 lines

Test #30:

score: 0
Accepted
time: 8ms
memory: 3796kb

input:

76 1000
(((((((((((R50((((((((((((((((((L53(((((((((((R11)168222785R9)947821376)85265860(((R38(((((((((((((D75((((((((R48(R32)519933295(((((((R42R32R47)587718335)271461507)607434871)313284630)778030888)573269997)565353778)277513747)478872341(((R46)382171771)33907928)233448212)61861779)35049968)21452...

output:

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 99 100 101 102 ...

result:

ok 76 lines

Test #31:

score: 0
Accepted
time: 9ms
memory: 3904kb

input:

79 995
((((((((D47(L65(((((((((U52((((((U2(((D66)530618138(((((((((((((((((((((((((((((((((((((((((((((((R5((((((((((U45)989858722)881494058)112442843)249530306(L25R42)660886045)297418603)345870975)419463792)155396193)286817113)68430022)542106902)303509880L75L62)956833270)961771932)735425049)8916119...

output:

1 2545 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 5758 46 6128 48 49 50 51 1498 53 54 55 56 57 58 59 60 2609 62 63 64 65 66 67 68 69 70 71 72 73 74 75 5096 77 78 79
80 2872 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

result:

ok 79 lines

Test #32:

score: 0
Accepted
time: 12ms
memory: 4052kb

input:

94 990
(((((U30(((((((L64(((((((((((((((((((((U68)557167250)570265657((((((((((((((U80)630739133D67)511417917(((((((U66((((((((((((U10(((((R77L65((((((((D65(((((D41)494465953)293222233)264849950((D41L26)679755015)787435538)248186046R32L41)597076989)993942230)660045138)800887764)32284679)511409284)49...

output:

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 5357 28 29 5959 31 32 33 34 35 36 37 38 39 40 591 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 7265 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 5928 94
95 96 97 98 99 100...

result:

ok 94 lines

Test #33:

score: 0
Accepted
time: 4ms
memory: 4020kb

input:

55 999
(((L1D44((((((((D42(((R22)875541515(((((((((L34)16876892(((((((((((((((((((((((((L5)219732817(((((((U23(((((R31((R42(((((U37)964375304)846028713)140574120(D43)705642642)905676261((((((((L38)768803297)622498178)471972392)912435243)480895925)940026403R12)31548098)391245439)404743160L11)27995288...

output:

2532 2425 2192 2930 2925 2920 1825 1307 28 29 30 31 32 33 34 35 36 531 2966 1705 659 630 2441 330 550 137 1911 2227 2305 1202 848 1123 2060 1837 643 919 589 570 2777 1152 2637 1839 23 24 881 2550 889 317 1728 1417 1853 2493 704 649 594
56 958 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 ...

result:

ok 55 lines

Test #34:

score: 0
Accepted
time: 2ms
memory: 4076kb

input:

56 1000
(((((((((U22((((((((((((((((((((((((((((((((D25((((((((L29L31(((((D24(U10R9(((((((((((L16((D15((U48)366659685)377901242)473108671(D37((((((((((U7)518460432R3)838921491)290336217R28D46)97980240(R32)210586952)511510305((U56)335350561)203603208)777953381)438133839)324474115)762191631D21)3922474...

output:

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 1929 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 99 100 101 10...

result:

ok 56 lines

Test #35:

score: 0
Accepted
time: 5ms
memory: 4040kb

input:

59 999
(L8(((((((((((D27(((((((((((((((((((L53(((((R44(((((((((((((((((((((R6((((((R32(((L16)168268383((((((((((((((((((D3)637151922)807645588D42)207039635)516247987)722328571)991326517)682837227)499515206)135672500)122756771)465996105)93936281)722166697)668791388)873700376)628109827)650864579)16189...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 416 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 1183 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 1733 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok 59 lines

Test #36:

score: 0
Accepted
time: 13ms
memory: 3956kb

input:

98 998
(((((((((((((((((((L24((((((((((((((R94(((((((((((((((((L95)60032613)742635302)217749651)285513169((((U53R81)794004556((((((((R55)922204635)340786845((((R79L68)592739909R71R64R59)593598892)815715124)855764549)370601107)133815820)704625239((((((((D25)109422262)273564129)16884544)60687147)70260...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 4713 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
99 100 101 10...

result:

ok 98 lines

Test #37:

score: 0
Accepted
time: 11ms
memory: 4120kb

input:

91 1000
(((((D12(D29(((U24((D25((((((((L64((L78((((((((((((((((L89((R7(((((((((((((D9(((((((U78(((((R26)581322662)792685033)433242647)37269661)412323701)323034713(((((R51U33(((((((((((L88L66)498783944)851639923)936414517)637047563)275950491(U24)282115840R84)115244794)316237073)576652716)148172309((U...

output:

1 2 3 4 5 6 7 8 7323 10 11 5394 13 14 15 16 17 18 19 20 21 22 23 5783 7055 26 27 28 2572 30 31 32 9 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 1303 3127 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 9...

result:

ok 91 lines

Test #38:

score: 0
Accepted
time: 10ms
memory: 4204kb

input:

95 995
(((((((((((L82((((((L59((((((((((L61(((((((U67((((((((((D7((((U29((U64((D57((((((R58(R17)90830461)166247483)86289668)697006059(D68((((((((((((((U52)173712347(U47(D58)947042350)621746430U74(U1((((((((U64)3421766R31)659425969)902954799)502426352)774376754)11771039)505428774)172138413)342351193)...

output:

1 2 3 4 5 6 5550 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1522 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 5786 68 69 70 71 72 73 74 75 76 77 78 79 80 81 8537 83 84 85 86 87 88 89 90 91 92 93 94 95
5577 97 98 99 1...

result:

ok 95 lines

Test #39:

score: 0
Accepted
time: 0ms
memory: 10468kb

input:

100 998
D99D12U93D44(U73U66R55L82(R53L82R71(D3U76R78U51)222439665R16R27L54U24R30R7D52R74L5L3U72U28R2U42D28D99R33R11U90R42L41(D78U86U65R30((U90L50U17L49D75D21U66R21D30D83L7L87L40D100L96U80L29L77R73D74R68U2U20R53D49U53R100U6D88(D92L17L60D51D12D5(D80U35D93L5(U74L53D87R79L34D78D86R3R89D100)380658131D33D...

output:

484 8320 1723 4 5376 4114 7 8 9 6555 11 2897 13 1982 4673 8849 5652 8718 7175 8260 21 1397 7891 2061 3714 5201 27 372 29 4514 4700 32 8174 7580 1593 36 37 1812 7627 40 41 2030 8235 9944 45 1851 8458 6706 7962 50 9213 6512 6606 54 55 56 8934 4109 1653 1253 61 8878 1190 64 1088 74 8806 188 9182 70 396...

result:

ok 100 lines

Test #40:

score: 0
Accepted
time: 3ms
memory: 6912kb

input:

80 999
L59(L76U76L50L54U69U65U6R18L3L4R28(R58R1D6U31L53L22U30(R78R40D68D19R75U71L2L72R61R52)206283300D80L62R14D17R43R50(U36D37U8D38R52R58R65U45D67(L35R18D77U13D34R8D59U75R69D53U30L28U75U4D25)236362920)297291174(R54U67D28U47D36D23U28R59L78D43L52R43D57L48D43L49D25(R65R16(D61L9L26(U13U54U30U56L30R80R67...

output:

177 3856 4959 288 5890 1185 1175 3300 3041 2477 1098 3657 69 911 1274 1152 3198 4680 4106 2424 5948 3066 740 4403 2269 3883 6111 197 5707 2411 4261 592 2972 5923 5023 5887 1323 91 3174 1691 4168 2048 354 791 5029 2514 2503 6086 5908 900 487 3197 2333 6307 2906 438 306 3993 1228 5698 4558 3209 2478 3...

result:

ok 80 lines

Test #41:

score: 0
Accepted
time: 3ms
memory: 5300kb

input:

61 999
U27D58L13U43(D14(R19R55R53D18D24D15R5(U51R31R53U21)95616423L50U37R44U7U32U43(R46U28R40U8U32R26D57U51R45L23R35D57L54L56R36U47L54D13(D31U25L7D43R21L5L42(D40U42D19R14R47U46D47(U41U46(L39D50U18L4U22R26U55L58D42R3R29D5L19D22R54(R59U58U51R45U20R41D14R51U17U59D22L5D20L8L46L21D57U21U58L57L34D40U4D28D...

output:

171 2953 2438 639 1897 2233 2755 910 529 3454 1476 3561 186 1393 2398 2572 327 2266 1007 539 1148 1838 3472 1814 3535 619 3692 2395 251 3017 2773 1844 3567 1830 1262 281 2914 773 1230 372 2049 3032 949 1241 899 137 742 1403 1963 3545 1677 826 3326 2349 988 2012 2517 2790 725 1592 1638
3322 245 1335 ...

result:

ok 61 lines

Test #42:

score: 0
Accepted
time: 0ms
memory: 4816kb

input:

50 999
U40R6D33D37U14R38D48R2(U11D37D9(L33U10(D2L5D7U38R11D13D32D39R38D17U24L33R46D6D29U41D45R25R19D43R10R33L11D37R7L9U1U32L20R49(D7R23L45R1R47D7L29L15D11D12L34U34(U14U25U31D34L26R48D18U2L14D20L7U50D47R12D42U36R41L46U15U1R18)274262145D15D7R48R11U7R44((U29L7U34R10U18U46R15R33L38R48D37D30D37D33D18R29D...

output:

1746 2255 1785 229 1103 660 479 1104 1425 1510 1277 2297 149 880 1215 2363 2452 2137 1491 1259 2192 806 1174 327 821 669 920 934 2122 198 1718 1044 440 156 938 543 2042 1686 1876 1615 1327 1175 292 2201 1068 1469 1672 168 1947 1400
974 1258 1130 2266 324 487 2473 2033 1043 1074 1638 748 1944 2268 44...

result:

ok 50 lines

Test #43:

score: 0
Accepted
time: 3ms
memory: 8828kb

input:

93 994
U55L71R78R9U8U14L9U74D83U69D68U3U9L2U34L43(R11R13U83D80L24D73U21U73L34R34R47L55R91U70U62R84D4((L7R1R91R36D66(D58D36R78(D19R73D68R85L2U51U92D27D46R20U13D84R10R74L60(D34D5D62L37D17U50L55L91R41L54R46R61R75D86R54U49U29R45(D32R60L63R38)202802680R54R69L66R37L58R73U67R65U31U78U82(L22R86D52R84R53R74D...

output:

1791 4757 3106 3076 2442 911 358 7078 976 3774 707 4743 3432 3840 988 3712 172 6357 5063 7370 4155 237 366 7202 1967 6886 5043 3283 221 5894 6811 1265 1154 2807 7231 6437 4998 431 531 1178 3779 5905 3894 4515 7791 2313 3981 4624 6713 1841 1092 3277 1607 1694 7846 307 3200 6762 3667 5083 3722 6239 65...

result:

ok 93 lines

Test #44:

score: 0
Accepted
time: 4ms
memory: 6032kb

input:

62 1000
L5U36L56D20U41U32R3R4L56L2D60U26D59L4U2D22D14(U49R50L38R26U42D24D53D14D32D36D20U11U37)852144190D9D9D30R23R58L55D35R26D62L40D2L57L26R46R47R50(D60(R50L49U40L58D37(U61(U21L45R37L53(U3D46D56U11U36D61R31R6D8U19D44R4(U48L12U19R44R54D23(L18D18R45D11D48L4(L42R54R39D4U55L34L1U20L19L12D59D56R43(D11L46...

output:

3629 998 934 3260 91 3340 132 2854 1548 3285 1371 3430 2602 1394 3843 1005 2967 3257 2982 1485 3671 682 1398 2251 2290 431 2796 2567 462 465 3387 3731 1659 3221 2938 3703 208 3262 2767 142 3844 3157 720 231 195 2406 2527 1971 3332 3137 2674 2395 2357 3023 1536 58 652 3412 1181 1518 559 3447
64 1785 ...

result:

ok 62 lines

Test #45:

score: 0
Accepted
time: 3ms
memory: 8540kb

input:

89 999
U10D28R61U60U79U19R56D56D86U38D66L88L82R61R74D64D78U9R26D59D60(R77L15L60(D6U18)776107383U13D34D88R54L23U4L24L75U88L24L63R84U33L35D31U71L34(D65U42(U74U6L3U26R32U69L53D30R25L58U12R3U68U37D43L22D23L70L33L53D55L25D43D38R5L59L16U27U80R9R18D69U55R27U83U25D2U52L79L39L45L88U64D66(U6U85R18U35L72R80R76...

output:

3481 3704 4936 2696 1746 2790 3730 6156 5251 756 6167 5917 5760 6654 3761 7207 4721 2136 4075 841 6462 71 4146 1180 1914 3593 7525 3427 6332 1401 6675 6556 3800 3751 3943 5451 1815 708 1976 5054 5870 438 3200 6817 5274 1938 6997 7301 5258 4446 2404 6525 6861 911 5654 5275 1430 2399 2284 3931 3027 51...

result:

ok 89 lines

Test #46:

score: 0
Accepted
time: 3ms
memory: 7276kb

input:

88 998
D40R17R17D34D44(L12D55(U53(R73L38(U9U6U17L83R60R18R46U32D72R53L28R61R38D34U27U79D27D53U74U19D67)857749622U48U5L71D79D81R16(U10D1R17L68U7L15(R37L12L24L5R74D59L7D49D14U57U58D2U11R58U32R58D49D26L67U15U64D75U76U62(L37R66D48L46R37(R8D64L6R82R3D65R55L42R11U11L16D88D65U38D62D65U68R7U26L28)789626956U...

output:

6975 5396 3092 1397 5019 5842 5352 1546 525 5498 6024 1680 503 5561 3714 4241 3072 3808 932 6922 922 1091 3939 244 4664 5389 4220 4987 1481 887 972 3379 2008 5212 242 5231 3965 7514 4803 3559 353 6263 7094 7304 1726 5321 7440 1420 3155 7135 1603 3093 7090 5134 809 56 1675 5477 272 4442 5740 3529 142...

result:

ok 88 lines

Test #47:

score: 0
Accepted
time: 5ms
memory: 6908kb

input:

79 995
R10R69L59(U70U68L32U15D23D25L50U52R50U26D16L75D47D74U68(L44U37L45U25R22(R69D31L34R18U10D21D16L51D69L57D35L11R20(L10D46U40R40D74U70L43L71U53D9D25L61(U32U43L31D42U75U27(U24L68R55R60)660833394(R61L74D25R70U70R68D40L29(L36L48U33R41D59U63D23D46L5U9U65L21R11L18U67R26D12U67U49(L32D55(D77U62D65L39R14...

output:

3070 5068 5862 5145 4508 5523 3385 3593 2 4499 2602 2410 1757 4839 6013 4929 3732 5082 812 3840 4910 71 1143 979 3987 1826 4036 520 4669 4981 5305 1745 670 5826 3305 5989 4854 526 315 2870 510 1663 940 1879 2277 5235 3199 1299 4779 3134 6048 5375 729 6064 327 3926 1697 1210 91 495 1698 2270 1031 305...

result:

ok 79 lines

Test #48:

score: 0
Accepted
time: 3ms
memory: 6804kb

input:

88 999
L81R47R26U21L10U72L74D7R9(L15(L32(R76(R2L10U42L5R10L53U66R70D22L7U87D37R60R29R11(D23D87D38D75R20D1L79R33L12R37U14U79D77U31U48R32L5(U7U26L58(R29R19L70D8)232868561L78U82D56U14L71((D53L26D33D40U25L43R36L31R34L32L33(R39D79D21D69(D19U73R68D16U29R65L67L46D69R8D19U79L53D11U43U29U74D52D32R39R67U26U47...

output:

5462 2061 5787 2371 3907 6366 4643 4090 6104 7249 11 6578 2885 7511 3593 5569 1587 211 1608 7621 1749 4355 5253 1752 1452 6848 779 2630 4494 4884 3248 7550 7160 2353 6559 5538 7676 1994 1830 5541 7437 3842 1807 3570 992 7247 7211 4003 2548 1400 5082 1836 2833 888 2198 4574 207 5963 1431 508 1704 505...

result:

ok 88 lines

Test #49:

score: 0
Accepted
time: 46ms
memory: 3828kb

input:

100 998
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

8101 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 99 100
8201 ...

result:

ok 100 lines