https://cn.vjudge.net/problem/UVA-232
uva的题,结尾不能多\n,空格什么的
反正就是个中型模拟,题目多读就行
#define _CRT_SECURE_NO_WARNINGS
#include <cmath>
#include <iostream>
#include <stdio.h>
#include<algorithm>
#include <map>
#include <cstring>
#include <time.h>
#include <string>
#include<set>
using namespace std;
#define rep(i,t,n) for(int i =(t);i<=(n);++i)
#define per(i,n,t) for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
const int maxn = 2e5+ ;
const long long mod = ;
int n,m;
char s[][];
int id[][];
int vis[][];
int main() { int kase = ;
int first = ;
while (cin>>n&&n) {
if (first)first = ;else printf("\n");
cin >> m;
mmm(id, );
printf("puzzle #%d:\n", ++kase);
rep(i, , n)cin >> s[i]+;
int idx = ;
rep(i, , m)if (s[][i] != '*')id[][i] = ++idx;
rep(i, , n)rep(j, , m) {
if (s[i][j]!='*'&&(j == || s[i - ][j] == '*' || s[i][j - ] == '*'))id[i][j] = ++idx;
} puts("Across");
rep(i, , n)rep(j, , m) if(s[i][j]!='*'){
printf("%3d.", id[i][j]);
while (s[i][j] != '*'&&j<=m) { cout << s[i][j]; j++; }
cout << endl;
}
puts("Down");
mmm(vis, );
rep(i, , n)rep(j, , m) if (s[i][j] != '*'&&!vis[i][j]) {
printf("%3d.", id[i][j]);
int ii = i;
while (s[ii][j] != '*'&&ii <= n) { cout << s[ii][j]; vis[ii][j] = ; ii++; }
cout << endl;
}
//cout << endl;
} } /*
2 2
AT
*O
6 7
AIM*DEN
*ME*ONE
UPON*TO
SO*ERIN
*SA*OR*
IES*DEA
1 1
* */