Easy Problem(cdOJ1644)
#include #include #include #include #include #include #include #include #include #include using namespace std; struct my { int left; int right; }stir[1000]; int main() { int i,j,k; char go[100][100]; int num=0; int t; int n,m; cin>>t; while (t--) { num++; cin>>n>>m; for (i=0;i>go[i]; int l,r; stir[0].left=stir[0].right=-1; for (i=0;i
Easy Problem
Time Limit: 1000 ms Memory Limit: 65536 kB Solved:122 Tried: 554
Description
Many students won prizes in UESTC Annual Amateur Contest last year. Yangsir asked Loveqinqin to send prizes to the winners' dormitories. Poor Loveqinqin found that these dormitories were scattered on several different floors of the dorm building. Loveqinqin drew the map of the dorm building as showed in the following picture. Rooms colored red contained winners. Loveqinqin can only go to upstairs throught the stairs at either end of each floor. Assume that it takes Loveqinqin one minute to walk from a room to a neighbour room. Going through the stairs from Floor i to Floor i + 1 also takes one minute. Note that if a room is near to the stairs, the time Loveqinqin needs to walk between stairs and that room is one minute. Loveqinqin could start at either end of the Floor 1 and would stop at either end of the topmost floor. Please find a route which takes the minimum minutes, through which Loveqinqin can send prizes to all winners.
Input
There are multiple test cases. The first line of the input will be an integer T (T <= 100) indicating the number of test cases. For each test case, in the first line there are two numbers: N M, indicating the number of floors (1 <= N <= 100) and the width of each floor (1 <= M <= 100). The following N lines describe the distribution of the winners. The first line is about Floor 1, the second line is about Floor 2, ..., the last line is about Floor N. We use '*' to denote a room containing winners, '.' to denote other rooms, 's' to denote stairs. We guarantee that the width of each floor equals M. The two ends of each lines are the only places where 's' appears.
Output
For each test case, print "Case #t: "first, in which t is the number of the test case starting from 1. Then output the minimum minutes.
Simple Input
4 1 4 s*.s 3 3 s.s s*s s.s 4 4 s*.s s.*s s..s s*.s 4 6 s*...s s..**s s.*..s s..*.s
Simple Output
Case #1: 2 Case #2: 4 Case #3: 11 Case #4: 20
Hint
In the first case, Loveqinqin has to return to one of the ends of the first floor.This is really an easy problem. Come on!!!
Source
10th UESTC Programming Contest Preliminary
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
rails의 redirect_toRails에서 페이지 전환 중에 배열 오류가 발생하여 상당히 고민했을 때의 메모 레코드를 게시하고 게시 후 레코드 목록 화면으로 이동합니다. 레코드의 투고는 되어 있지만, 페이지 천이를 할 수 없다. (새 페이지에서...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.