标签:tps using for mod one time http set while
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+ 5; const long long mod = 998244353; int n,m; char s[15][15]; int id[15][15]; int vis[15][15]; int main() { int kase = 0; int first = 1; while (cin>>n&&n) { if (first)first = 0;else printf("\n"); cin >> m; mmm(id, 0); printf("puzzle #%d:\n", ++kase); rep(i, 1, n)cin >> s[i]+1; int idx = 0; rep(i, 1, m)if (s[1][i] != ‘*‘)id[1][i] = ++idx; rep(i, 2, n)rep(j, 1, m) { if (s[i][j]!=‘*‘&&(j == 1 || s[i - 1][j] == ‘*‘ || s[i][j - 1] == ‘*‘))id[i][j] = ++idx; } puts("Across"); rep(i, 1, n)rep(j, 1, 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, 0); rep(i, 1, n)rep(j, 1, 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] = 1; 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 * */
标签:tps using for mod one time http set while
原文地址:https://www.cnblogs.com/SuuT/p/9433008.html