<!-- bootstrap, bootwatch CSS -->
<link rel="stylesheet" href="/static/bootswatch/cerulean/bootstrap.min.css">
<!-- Magnific Popup core CSS -->
<link rel="stylesheet" href=/static/magnific-popup/dist/magnific-popup.css>
<link rel="stylesheet" href=/static/css/index.css media="screen">
<link rel="stylesheet" href=/static/css/mfp-fade.css media="screen">
<script src=/static/jquery/dist/jquery.min.js></script>
Toggle navigation
NTHU Online Judge
<li>
<a href=/users/notification/ id="notification">
<img src=/static/images/bell_blue.png id="notification_img"
title="You have 30 unread notifications."/>
<div id="notification_circle" class="center">
<b id="number">
30
</b>
</div>
</a>
</li>
<li class="nav-text-auth">
<a href="/users/profile/DSC103033210">
<i id="name-text">DSC103033210</i>
</a>
</li>
<li class="nav-text-auth"><a href="/users/logout/">Logout</a></li>
</ul>
</div>
</div>
</nav>
<!-- wrap all page elements to div -->
<div class="wrap-body container-fluid">
11859 - infix maze
</h2>
</div>
</h2>
</div>
Status |
Limits
<a class="btn btn-primary" href="/users/submit/11859">Submit</a>
</div>
×
Close
Limits
<tr>
<th>Case 1</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 2</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 3</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 4</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 5</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 6</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 7</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 8</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 9</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
<tr>
<th>Case 10</th>
<td>1 sec</td>
<td>32 MB</td>
</tr>
</tbody>
</table>
</div>
</div>
Description
Determine whether a matrix contains at least a legal infix expression which need to be from the top-left corner to the bottom-right corner. If yes, convert it based on the postfix notation.
There are some rules to be followed.
- Each cell can be reached by four directions(up, down, right, left).
- Matrices are consisted of 1~9, +,-,*,/, (, )
- Each cell can be visited at most one time.
- The priority directions are: down>right>left>up.
- No negative number. EX: - 5 + 3 is illegal.
Input
First line is total number of matrices.
Second and third line are matrix width nad height.
Width and height <100.
Following lines are matrix.
Output
Repeat all inputs.
For matrix, there is a white space after every elements.
If there is a legal infix expression from the top-left corner to the bottom-right corner, output
Yes
infix expression ( there is a white space after every elements.)
postfix expression ( there is a white space after every elements.)
If No, output
No
Sample Input Download
<textarea id='11859_sampleIn' class='panel-body sampleIO' readonly>1
3
3
1 5 4
+ - *
+ 6 8 </textarea>
Sample Output Download
<textarea id='11859_sampleOut' class='panel-body sampleIO' readonly>1
3
3
1 5 4
+ - *
+ 6 8
Yes
15 - 68
15 68 -
</textarea>
Tags
<script> var pid = 11859; </script> <script src="/static/problem/js/problem.js"></script></div>
<!-- footer -->
<footer>
<div class="navbar navbar-inverse navbar-fixed-bottom sticky-footer container-fluid">
<div class="navbar-collapse collapse">
<p class="navbar-text col-lg-4">Contact us: nthucsoj@gmail.com</p>
<p class="navbar-text col-lg-6">© NTHU Online Judge 2015, Templates are from Bootswatch Project</p>
<p id="time" class="navbar-text">2018/05/02 16:25:57</p>
</div>
</div>
</footer>
<!-- JS -->
<script src=/static/bootstrap/dist/js/bootstrap.min.js></script>
<script src=/static/js/function.js></script>
<script src=/static/magnific-popup/dist/jquery.magnific-popup.min.js></script>
<script src=/static/js/popup-setting.js></script>
<script src=/static/js/base.js></script>
<script src=/static/js/clock.js></script>
Time | Memory |
---|