每日一题 uva-232 模拟+输出要求很严格
Posted suut
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了每日一题 uva-232 模拟+输出要求很严格相关的知识,希望对你有一定的参考价值。
https://cn.vjudge.net/problem/UVA-232
uva的题,结尾不能多 ,空格什么的
反正就是个中型模拟,题目多读就行
#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(" "); cin >> m; mmm(id, 0); printf("puzzle #%d: ", ++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 * */
以上是关于每日一题 uva-232 模拟+输出要求很严格的主要内容,如果未能解决你的问题,请参考以下文章