QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#323185#4833. Tetra-puzzlehotboy27030 1678ms3856kbC++148.4kb2024-02-08 19:51:092024-02-08 19:51:09

Judging History

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

  • [2024-02-08 19:51:09]
  • 评测
  • 测评结果:0
  • 用时:1678ms
  • 内存:3856kb
  • [2024-02-08 19:51:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define MASK(i) (1LL<<(i))
#define BIT(mask,i) (((mask) >> (i))&1LL)
string best_move = "TLZOI";
const ll INF = 1e9;
pll piece[][4]={
{{0,0},{1,0},{-1,0},{0,-1}},
{{0,0},{0,1},{0,2},{1,0}},
{{0,0},{0,1},{-1,1},{1,0}},
{{0,0},{0,1},{1,0},{1,1}},
{{0,0},{0,1},{0,2},{0,3}},
};
ll penalty[5][5];
void cv_to_board(ll state,ll board[5][5]){

    ll ptr = 0;
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++,ptr++){
            board[i][j] = BIT(state,ptr);
        }
    }
}
ll to_state(ll board[5][5]){
    ll res = 0;
    ll ptr = 0;
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++,ptr++){
            res ^= board[i][j]*MASK(ptr);
        }
    }
    return res;
}
ll mx[] = {0,0,1,-1};
ll my[] = {-1,1,0,0};
ll evaluate(ll state){
    if (state<0)return INF;
    ll board[5][5];
    ll res = 0;
    cv_to_board(state,board);
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++){
            res += penalty[i][j] * board[i][j];
        }
    }

    auto valid = [&](pll pnt){
        if (pnt.fi >= 0 && pnt.fi<5 && pnt.se >= 0 && pnt.se<5 && board[pnt.fi][pnt.se]==0)return 1;
        else return 0;
    };
    ll holes = 1;
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++){
            if (board[i][j]==0){
                holes++;
                queue <pll> q;
                q.push({i,j});
                board[i][j] = 1;
                while (!q.empty()){
                    pll u = q.front();
                    q.pop();
                    for (ll k = 0;k < 4;k ++){
                        pll nw = {u.fi+mx[k],u.se+my[k]};
                        if (valid(nw)){
                            q.push(nw);
                            board[nw.fi][nw.se] = 1;
                        }
                    }
                }
            }
        }
    }
    return res*holes;
}
void print_move(ll cur_state,ll nxt_state){
    ll ptr = 0;
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++,ptr++){
            if (BIT(nxt_state,ptr)){
                if (BIT(cur_state,ptr)){
                    cout<<'#';
                }
                else{
                    cout<<'*';
                }
            }
            else{
                cout<<'.';
            }
        }
        cout<<endl;
    }
}
void print_state(ll state){
    ll board[5][5];
    cv_to_board(state,board);
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++){
            cout<<board[i][j];
        }
        cout<<endl;
    }
}
ll f_clear(ll state){
    ll board[5][5];
    cv_to_board(state,board);
    ll row[5]={},col[5]={};
    for (ll i = 0;i < 5;i ++)col[i] = row[i] = 1;
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++){
            col[j] &= board[i][j];
            row[i] &= board[i][j];
        }
    }
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++){
            if (col[j] || row[i])board[i][j] = 0;
        }
    }
    return to_state(board);
}
vector <pll> all_move(ll state,ll type){
    ll board[5][5];
    vector <pll> ans_move;
    cv_to_board(state,board);
    auto valid = [&](pll pnt){
        if (pnt.fi >= 0 && pnt.fi<5 && pnt.se >= 0 && pnt.se<5 && board[pnt.fi][pnt.se]==0)return 1;
        else return 0;
    };
    for (ll flip = 0;flip <= 1;flip++){
        for (ll rot = 0;rot < 4;rot++){
            vector <pll> cur_piece;
            for (ll i = 0;i < 4;i ++){
                pll cur = piece[type][i];
                if (flip){
                    cur.fi = -cur.fi;
                }
                for (ll j = 0;j < rot;j ++){
                    ll x = cur.fi,y = cur.se;
                    cur.fi = y;
                    cur.se = -x;
                }
                cur_piece.push_back(cur);
            }
            for (ll i = 0;i < 5;i ++){
                for (ll j = 0;j < 5;j ++){
                    bool ok = 1;
                    for (ll k = 0;k < 4;k ++){
                        pll cur = cur_piece[k];
                        ok &= valid({cur.fi+i,cur.se+j});
                    }
                    if (ok){
                        for (ll k = 0;k < 4;k ++){
                            pll cur = cur_piece[k];
                            board[cur.fi+i][cur.se+j] = 1;
                        }
                        ll nxt_state = to_state(board);
                        ll end_state = f_clear(nxt_state);
                        ans_move.push_back({nxt_state,end_state});
                        for (ll k = 0;k < 4;k ++){
                            pll cur = cur_piece[k];
                            board[cur.fi+i][cur.se+j] = 0;
                        }
                    }
                }
            }
        }
    }
    return ans_move;
}
pll greedy(ll cur_state,ll type){
    vector <pll> choices = all_move(cur_state,type);
    ll ans_eval = INF;
    pll ans = {-1,-1};
    for (auto x:choices){
        ll val = evaluate(x.se);
        if (val < ans_eval){
            ans = x;
            ans_eval = val;
        }
    }
    return ans;
}
ll DEPTH = 5;
ll plan_ahead(ll cur_state,string coming){
    for (auto x:coming){
        ll type = 0;
        for (ll k = 0;k < sz(best_move);k ++){
            if (best_move[k] == x){type = k;break;}
        }
        cur_state = greedy(cur_state,type).se;
        if (evaluate(cur_state)==INF){
            return cur_state;
        }
    }
    return cur_state;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
    string task;
    cin>>task;
    ll ptr = 0;
    for (ll i = 0;i < 5;i ++){
        for (ll j = 0;j < 5;j ++,ptr++){
            ll dist_i = min(abs(i-0),abs(i-4));
            ll dist_j = min(abs(j-0),abs(j-4));
            penalty[i][j] = MASK(dist_i+dist_j);
//            cout<<penalty[i][j]<<' ';
        }
//        cout<<endl;
    }
    if (task == "prepare"){
        ll n;
        cin>>n;
        ll cur_state = 0;
        vector <string> s(n);
        for (auto &x:s)cin>>x;
        for (ll i = 0;i < n;i ++){
            string cur;
            ll best_eval[2];
            best_eval[0] = best_eval[1] = INF;
            function<void(int)> backtrack = [&](int t){
                if(t==n || t == i+DEPTH){
                    ll cur_eval = evaluate(plan_ahead(cur_state,cur));
                    for (ll j = 0;j < 2;j ++)if (cur[0]==s[i][j])best_eval[j] = min(best_eval[j],cur_eval);
                    return;
                }
                for (ll j = 0;j < 2;j ++){
                    cur.push_back(s[t][j]);
                    backtrack(t+1);
                    cur.pop_back();
                }
            };
            backtrack(i);
            ll type[2];
            for (ll j = 0;j < 2;j ++){
                for (ll k = 0;k < sz(best_move);k ++){
                    if (best_move[k] == s[i][j]){type[j] = k;break;}
                }
            }
            pll ans0 = greedy(cur_state,type[0]);
            pll ans1 = greedy(cur_state,type[1]);
//            cout<<"PENDING "<<s[i]<<endl;
            char choose = s[i][0];
            cur_state = ans0.se;
//            cout<<"EVAL "<<best_eval[0]<<' '<<best_eval[1]<<'\n';
            if (best_eval[0]>best_eval[1]){choose = s[i][1];cur_state=ans1.se;}
            if (evaluate(cur_state)==INF)assert(0);
//            cout<<evaluate(cur_state)<<endl;
//            print_state(cur_state);
            cout<<choose;
        }
    }
    else{
        ll n;
        cin>>n;
        ll cur_state = 0;
        while (n--){
            char x;
            cin>>x;
            ll type;
            for (ll i = 0;i < 5;i ++){
                if (x==best_move[i]){
                    type = i;
                    break;
                }
            }
            pll ans=greedy(cur_state,type);
            print_move(cur_state,ans.fi);
            cur_state = ans.se;
//            print_state(cur_state);
        }
    }
}
// 7 10 3 9 8 9 10 11
/*
prepare
88
ZL OL OT IT LO ZL OI ZT TO OI OL OL LZ ZT TL TZ IO ZL TZ TO IL LO ZT OL LT ZI TZ IL LT ZL OT TI ZO ZO ZT OZ TL TL LO OI TO OZ LI ZO ZT ZT IO IZ OZ ZO ZI ZO IO IO TI OL IL IT IL TL TL ZL IT IT ZO IO OL IL ZI TO OL IL ZI LZ LT IL LI ZO IL TL IT LI ZI OL TO OZ IZ OZ
*/

详细

Test #1:

score: 100
Accepted
time: 8ms
memory: 3844kb

First Run Input

prepare
6
TO LO ZI LI LT LT

First Run Output

OLIITL

Second Run Input

play
6
O
L
I
I
T
L

Second Run Output

**...
**...
.....
.....
.....
##..*
##***
.....
.....
.....
##..#
.*...
.*...
.*...
.*...
#...#
*....
*....
*....
*....
....#
.....
....*
...**
....*
....#
.....
....#
***##
*...#

result:

ok good job!

Test #2:

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

First Run Input

prepare
1
ZI

First Run Output

I

Second Run Input

play
1
I

Second Run Output

****.
.....
.....
.....
.....

result:

ok good job!

Test #3:

score: 100
Accepted
time: 16ms
memory: 3768kb

First Run Input

prepare
10
LO TZ ZO OI OL ZL ZO TL OZ LO

First Run Output

OTOILZOLOO

Second Run Input

play
10
O
T
O
I
L
Z
O
L
O
O

Second Run Output

**...
**...
.....
.....
.....
##...
##...
.*...
**...
.*...
#..**
#..**
.....
#....
.....
#..##
#..##
.....
#****
.....
#..##
#..##
...*.
...*.
...**
#...#
#...#
....*
...**
...*#
#..**
#..**
.....
...#.
...#.
#..##
#..##
...**
...#*
...#*
#..**
#..**
.....
.....
.....
#**##
#**##
.....
.....
.....

result:

ok good job!

Test #4:

score: 100
Accepted
time: 57ms
memory: 3648kb

First Run Input

prepare
29
ZT OT ZL LT ZI LO IZ LT OI ZT ZT OL ZI LT LZ TZ IL ZI OT LZ LT LZ OT OI IO OZ IZ ZL ZL

First Run Output

TTLLILZLIZTOILLTIITZTZOIIZIZL

Second Run Input

play
29
T
T
L
L
I
L
Z
L
I
Z
T
O
I
L
L
T
I
I
T
Z
T
Z
O
I
I
Z
I
Z
L

Second Run Output

....*
...**
....*
.....
.....
.*..#
***##
....#
.....
.....
.#..#
.....
....#
....*
..***
.#..#
.....
*...#
*...#
**###
.#..#
.*...
#*..#
#*..#
.*...
....#
.....
#***#
#*..#
.....
....#
.....
.....
##**#
...**
....#
.....
.....
*....
***##
....#
.....
.....
#****
.....
..**#
...**
.....
.....
.....
...

result:

ok good job!

Test #5:

score: 100
Accepted
time: 69ms
memory: 3596kb

First Run Input

prepare
36
TI ZT IT IT OT OZ IL TZ ZO LO LZ ZL OT ZI IL OT OT ZI ZT TZ TI LT LO OL IL OL IZ OZ OL ZL LT IO ZO ZL ZO LT

First Run Output

ITIIOOIZOLLLOILOTIZZILLOLOIOOLTIZLOL

Second Run Input

play
36
I
T
I
I
O
O
I
Z
O
L
L
L
O
I
L
O
T
I
Z
Z
I
L
L
O
L
O
I
O
O
L
T
I
Z
L
O
L

Second Run Output

****.
.....
.....
.....
.....
####*
...**
....*
.....
.....
.....
...##
****#
.....
.....
.****
...##
.....
.....
.....
.####
...##
.....
**...
**...
.####
**.##
**...
##...
##...
..###
#..##
#****
#....
#....
**###
#**##
.....
#....
#....
**...
**...
.....
#....
#....
##...
##...
**...
#*...
#*...
...

result:

ok good job!

Test #6:

score: 100
Accepted
time: 97ms
memory: 3844kb

First Run Input

prepare
57
LT OI TL IZ OT TL LT TI LO LT LO LO OL IO LI IT TZ TZ IO ZT TI OT OI TL TL ZT TZ OL OI LI OZ ZI TO LZ IO IO LT OZ TO OZ IZ TZ LT ZO TO TZ OT LT ZO OL IL LO ZT OZ OL IL ZI

First Run Output

TITZOLLTOLLLOILIZTITIOOTTTTLOLZIOLIILZTZIZLOOZTLZOILTZOLI

Second Run Input

play
57
T
I
T
Z
O
L
L
T
O
L
L
L
O
I
L
I
Z
T
I
T
I
O
O
T
T
T
T
L
O
L
Z
I
O
L
I
I
L
Z
T
Z
I
Z
L
O
O
Z
T
L
Z
O
I
L
T
Z
O
L
I

Second Run Output

....*
...**
....*
.....
.....
....#
...##
****#
.....
.....
.*..#
***##
.....
.....
.....
.#**#
...**
.....
.....
.....
.####
...##
.....
**...
**...
*####
***##
.....
##...
##...
**...
.*...
.*...
##...
##...
#...*
...**
....*
#....
#....
#...#
...##
....#
#..**
#..**
#....
***#.
*....
#..#.
#..#.
...

result:

ok good job!

Test #7:

score: 100
Accepted
time: 177ms
memory: 3628kb

First Run Input

prepare
88
ZL OL OT IT LO ZL OI ZT TO OI OL OL LZ ZT TL TZ IO ZL TZ TO IL LO ZT OL LT ZI TZ IL LT ZL OT TI ZO ZO ZT OZ TL TL LO OI TO OZ LI ZO ZT ZT IO IZ OZ ZO ZI ZO IO IO TI OL IL IT IL TL TL ZL IT IT ZO IO OL IL ZI TO OL IL ZI LZ LT IL LI ZO IL TL IT LI ZI OL TO OZ IZ OZ

First Run Output

LOOTLZITTOLOLZLZIZZOILZLLZTLLLTTZZZZLLLOOOLZZZIZZZIZOOTOIILTTZIIZILIITOLZLLIIZILTLZLTOIO

Second Run Input

play
88
L
O
O
T
L
Z
I
T
T
O
L
O
L
Z
L
Z
I
Z
Z
O
I
L
Z
L
L
Z
T
L
L
L
T
T
Z
Z
Z
Z
L
L
L
O
O
O
L
Z
Z
Z
I
Z
Z
Z
I
Z
O
O
T
O
I
I
L
T
T
Z
I
I
Z
I
L
I
I
T
O
L
Z
L
L
I
I
Z
I
L
T
L
Z
L
T
O
I
O

Second Run Output

***..
*....
.....
.....
.....
###**
#..**
.....
.....
.....
.**..
#**##
.....
.....
.....
.##..
.....
....*
...**
....*
.##..
.....
....#
***##
*...#
.##..
.....
....#
**...
#**.#
.##..
.....
****#
##...
###.#
.##..
.....
.....
##***
###*#
.##..
.....
....*
...**
....*
.##**
...**
....#
...##
....#
...

result:

ok good job!

Test #8:

score: 100
Accepted
time: 217ms
memory: 3580kb

First Run Input

prepare
105
LI LI OI TL OZ LZ IL IZ IL TI IL IO OT LT LO ZO LI LZ OI IL ZT IT LZ IZ IZ LI IT LI IO TI ZL OI IT LO TZ OI IL OL IL OT IL OZ LT IO OL OL LO ZO TI LI LI LI ZO ZI LI OL TI TZ LO LT IL LZ IL OL ZT LT IZ IL TZ IT OZ TL ZI IZ IZ TO IT IO TO TI TO TZ ZT IZ LI IL ZI TI TL TZ TO LI LO OL IL IL ...

First Run Output

ILOLOLLIITIIOTOOLZOLZILIZLILITLIIOTILLLOIOLOLOLZTILLZZLOITOLIZLLTLILZTOTZIITIOTTTZZZLLIILZOLLLIIZOLLZIIIL

Second Run Input

play
105
I
L
O
L
O
L
L
I
I
T
I
I
O
T
O
O
L
Z
O
L
Z
I
L
I
Z
L
I
L
I
T
L
I
I
O
T
I
L
L
L
O
I
O
L
O
L
O
L
Z
T
I
L
L
Z
Z
L
O
I
T
O
L
I
Z
L
L
T
L
I
L
Z
T
O
T
Z
I
I
T
I
O
T
T
T
Z
Z
Z
L
L
I
I
L
Z
O
L
L
L
I
I
Z
O
L
L
Z
I
I
I
L

Second Run Output

****.
.....
.....
.....
.....
####*
..***
.....
.....
.....
**...
**###
.....
.....
.....
##***
....*
.....
.....
.....
**...
**..#
.....
.....
.....
##...
##..#
.*...
.*...
**...
#..*.
#***#
.....
.....
#....
#..#.
...*.
...*.
...*.
#..*.
#****
.....
.....
.....
#....
....*
...**
....*
.....
#....
...

result:

ok good job!

Test #9:

score: 100
Accepted
time: 401ms
memory: 3564kb

First Run Input

prepare
204
TZ TL OL TL ZO OT ZO LI TZ IO TI OL LZ TI TO ZT IL OI LT IT OZ TI OT TI ZL ZI ZO TI OI ZI TL LI ZI IO TI ZL LZ OL ZI TZ OI OI IZ LO IL LO IZ ZT ZT OL ZI OZ TL OI TI IT IZ ZL TI OI LZ OI TZ IZ IO OZ ZI TO OT TI TO IO IZ OI TZ LT TZ ZI OL LO LO OZ LO ZL LZ TZ LT TO OL LO LT TZ TL OZ ZO LO ...

First Run Output

TLLLOOZITIILZITTLOLTOIOTZZZIOZTLIIILZLITOIILILITTLZOTOTIZLTOLOZIIOIOTITOIOTLZILOLOOLZTLOLLLZLOZLOLIZTIOLLTZILOOLZIIILITIIZTIZIIIIZZLZLTIIITLTTLTTTLZOOLIZTLIILIOILTIZOLOIIOOZZOTLTTIZTIIIZITILLZOIOLIZTLTTTL

Second Run Input

play
204
T
L
L
L
O
O
Z
I
T
I
I
L
Z
I
T
T
L
O
L
T
O
I
O
T
Z
Z
Z
I
O
Z
T
L
I
I
I
L
Z
L
I
T
O
I
I
L
I
L
I
T
T
L
Z
O
T
O
T
I
Z
L
T
O
L
O
Z
I
I
O
I
O
T
I
T
O
I
O
T
L
Z
I
L
O
L
O
O
L
Z
T
L
O
L
L
L
Z
L
O
Z
L
O
L
I
Z
T
I
O
L
L
T
Z
I
L
O
O
L
Z
I
I
I
L
I
T
I
I
Z
T
I
Z
I
I
I
I
Z
Z
L
Z
L
T
I
I
I
T
L
T
T
L
T
T
T...

Second Run Output

....*
...**
....*
.....
.....
*...#
***##
....#
.....
.....
#***#
.*...
....#
.....
.....
***..
*#...
....#
.....
.....
###**
##.**
....#
.....
.....
.....
##.##
....#
**...
**...
.....
##.##
...*#
##.**
##..*
..*..
##*##
..*##
##*##
##..#
..#..
*....
**###
*....
##..#
..#..
#.*..
..*..
#.*..
##*.#
...

result:

ok good job!

Test #10:

score: 100
Accepted
time: 609ms
memory: 3584kb

First Run Input

prepare
303
ZT ZT IO ZL LT TI LO LZ TI ZT TI ZT LO OZ ZT TL IT TZ ZI IL TL OZ IO OT ZT TI LT ZT ZL ZL IO LZ IZ IZ ZT TZ OT OI LZ IL IZ TL IT ZO TL ZL IZ IZ LO LO ZI TI OT ZT OI IT ZI IL OI TO ZL LI TL LT OI LZ TI TZ OL ZO OZ IL LO ZT ZL IT TO ZI TZ IL IO LO LT IT OL LO ZT OZ OI TI OL OZ ZI IT IO IT ...

First Run Output

TZILLILLIZTTLZTLITZITOOOTTTZLLOLIIZTTILIZTIOTLIILOIIOTOIIIOTZITLIZITOOOILTZITZTIOOLILOZOOILOZTIILTZZOTLTLTOIIIOTOTZLLOIOTILZZOLTOZIOOOZIILLLOOZIZLZLLOLITOTILLIOITOTZLZZLITIILLLLTZOZZLTIIIIITZZZTZOLILLZTZLLIZOOLLLOLTTOTIIOIIOTTOILZOIOZOLLIIILOZIOLIZTLLLOILOLZOZTIILZTOLLIOIOITOOLZZLOLLTLZIIITIILZILTZOOLT

Second Run Input

play
303
T
Z
I
L
L
I
L
L
I
Z
T
T
L
Z
T
L
I
T
Z
I
T
O
O
O
T
T
T
Z
L
L
O
L
I
I
Z
T
T
I
L
I
Z
T
I
O
T
L
I
I
L
O
I
I
O
T
O
I
I
I
O
T
Z
I
T
L
I
Z
I
T
O
O
O
I
L
T
Z
I
T
Z
T
I
O
O
L
I
L
O
Z
O
O
I
L
O
Z
T
I
I
L
T
Z
Z
O
T
L
T
L
T
O
I
I
I
O
T
O
T
Z
L
L
O
I
O
T
I
L
Z
Z
O
L
T
O
Z
I
O
O
O
Z
I
I
L
L
L
O
O
Z
I
Z
L...

Second Run Output

....*
...**
....*
.....
.....
....#
...##
...*#
...**
....*
****.
...#.
...#.
...#.
.....
####.
...#.
...#.
...#*
..***
###**
....*
....*
....#
..#.#
..*..
..*..
..*..
..*..
..#..
***..
*....
.....
.....
.....
###**
#...*
....*
.....
.....
.....
#...#
****#
.....
.....
**...
#**.#
.....
.....
.....
...

result:

ok good job!

Test #11:

score: 100
Accepted
time: 1016ms
memory: 3856kb

First Run Input

prepare
502
LO LI OZ LO IO ZT LO OZ OZ ZI IO OT ZO LZ IZ ZT TL TL LI IL IZ TO IO IL OL OL OL LO ZI OZ OZ ZO OZ IT OZ LZ TZ TO LZ TL ZL IZ LZ ZO ZL IO IL LI LT ZI OZ IZ OI TZ LI ZT IT LO TO ZI LT OT LZ OI LZ OZ LZ IT TO TI OI TO TO OI TZ ZL IO OZ ZO ZL LZ IZ OI TL TO TI LZ ZL ZL OZ TI ZI TL LO ZT LI ...

First Run Output

OLZLOZLOOIITZZZZTLIIITIIOOLOIZOOOIOZZOLTLILZLOLLLZOZIZLTIOOILOLIZOLITTIOTITZIZOZLIOLTTLLLOIITLZLOITOTTIZLIOTLZTLZTIZOZLOLLOZOLOTOIIZLIIOIILZZOIOIZTLTLOLZLITTLZLLIZLIOOLLZLZTIOLTOZTLLIOOLIOTLTILOILZOTOZOITZLZLOIOTTOZTLTOLLLZZZLIOIOLTIZLTOOITLLIZZIIOZZTZZOZTTOOIZLLLZTOIITOLLILLITIITIOOTTOOTZITLIIOLIZL...

Second Run Input

play
502
O
L
Z
L
O
Z
L
O
O
I
I
T
Z
Z
Z
Z
T
L
I
I
I
T
I
I
O
O
L
O
I
Z
O
O
O
I
O
Z
Z
O
L
T
L
I
L
Z
L
O
L
L
L
Z
O
Z
I
Z
L
T
I
O
O
I
L
O
L
I
Z
O
L
I
T
T
I
O
T
I
T
Z
I
Z
O
Z
L
I
O
L
T
T
L
L
L
O
I
I
T
L
Z
L
O
I
T
O
T
T
I
Z
L
I
O
T
L
Z
T
L
Z
T
I
Z
O
Z
L
O
L
L
O
Z
O
L
O
T
O
I
I
Z
L
I
I
O
I
I
L
Z
Z
O
I
O
I
Z...

Second Run Output

**...
**...
.....
.....
.....
##..*
##***
.....
.....
.....
##**#
...**
.....
.....
.....
*....
***##
.....
.....
.....
#..**
...**
.....
.....
.....
#**##
**.##
.....
.....
.....
..***
##*##
.....
.....
.....
**###
**...
.....
.....
.....
...**
##.**
.....
.....
.....
...##
##.##
.....
.....
****.
...

result:

ok good job!

Test #12:

score: 100
Accepted
time: 1678ms
memory: 3640kb

First Run Input

prepare
801
TL TL TZ LO LO TI ZI LI LZ OT OZ LT OL IL OZ OT OT IO ZL OZ OT ZL LO TO TZ TL OI ZO TI ZI TO IT ZL TZ IZ IT IL ZO IO LT ZI OZ LO TI OI TO LI IL LT LZ LT OZ IL LZ ZO ZT IL ZL TZ OI IZ TL ZI OT TO IL IO OZ IO ZL OT IZ IZ IT IT OI OZ ZL ZT ZT OI IT IZ IL ZL LZ TI IZ IZ IZ ZI LT ZT LZ IO LZ ...

First Run Output

LLTOLIZLZOZTLLOTTOLOTLOOTLOZIZTIZTZIIOOLZOLIOTLITLLOIZZTLZTOITIOTIIOILTIIIIIOLTTIIZILZIIZZILZLILZILZLOZOLZTOLIOLZITIZZIIZTOOLIZLLZLOTZILOIZIOZTTLTITIIOTLTIZIOTTLZLIOTITLLLZLIOTOOLLTOZLOIOLTIOLTITIIIITIOLTIOZIZLILTITIOIOOIOLTILLOLLTIITIIZOOZTOTTLILIOZZLIIZTOTLTTZLILTILIOTIZOOOTTOOLTLIZZLOILTLZTZZLTOI...

Second Run Input

play
801
L
L
T
O
L
I
Z
L
Z
O
Z
T
L
L
O
T
T
O
L
O
T
L
O
O
T
L
O
Z
I
Z
T
I
Z
T
Z
I
I
O
O
L
Z
O
L
I
O
T
L
I
T
L
L
O
I
Z
Z
T
L
Z
T
O
I
T
I
O
T
I
I
O
I
L
T
I
I
I
I
I
O
L
T
T
I
I
Z
I
L
Z
I
I
Z
Z
I
L
Z
L
I
L
Z
I
L
Z
L
O
Z
O
L
Z
T
O
L
I
O
L
Z
I
T
I
Z
Z
I
I
Z
T
O
O
L
I
Z
L
L
Z
L
O
T
Z
I
L
O
I
Z
I
O
Z
T
T
L
T...

Second Run Output

***..
*....
.....
.....
.....
###**
#...*
....*
.....
.....
..*..
#***#
....#
.....
.....
**#..
**...
....#
.....
.....
###.*
##***
....#
.....
.....
###.#
.....
****#
.....
.....
###*#
...**
....*
.....
.....
*....
***##
....#
.....
.....
#*...
**...
*...#
.....
.....
##...
##...
#...#
**...
**...
...

result:

ok good job!

Test #13:

score: 0
Stage 1: Program answer Time Limit Exceeded

First Run Input

prepare
1000
LT LT TO OL ZI OI IO IL TO IO IT LZ ZL ZL OL OI OL TO IO OL IZ ZO TZ OZ TL LT IZ LO IZ IO IO ZT IO TZ LI ZL ZT LT TL TL IL TI OZ LO TO OI LI LI OL ZI ZI TI IO OL ZT LT ZL ZI TZ TL OT ZL OT TI OL IT ZL IT OT LZ LZ LZ IL OZ LO ZI TZ IT TO TZ OZ ZI IT TZ LZ ZT ZO LT OT TI OZ LI OZ TL LO OT...

First Run Output

LLTOIIIIOOILZLLOOOILIZTZLLILIIIZITIZZLTTITZLOILLOIZTOOTTLIZLOLTIOILIOZLLIOLZZITTZITTLTZLTIOLOTOOITTIOZILIIIIOOIIITLZOZTLZZOOIOOITOILLZTOTTILLZLOIIZOOLILLOITIIZTITTITLZZIOTLLOZTLTLTZILOILTOZTZITTZZITILZIZIZIIZTIILZLOIITLOZZLOLOLOZITLTILZOTZLLIZTLLLZTTLIIZOOTOTIOOLLLIILLIIOIZZZZTLLOTLZOOLOIOOLZTLZILZO...

Second Run Input


Second Run Output


result: