最后一个点的玄学?

P1101 单词方阵

```cpp #include<cstdio> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<queue> #include<cmath> #include<cstring> using namespace std; const int maxn = 1e2; char ss[10] = "yizhong"; char s[maxn + 5][maxn + 5]; bool f[maxn + 5][maxn + 5]; int dx[] = {-1, 1, 0, 0, -1, 1, -1, 1}; int dy[] = { 0, 0,1,-1, 1, 1, -1, -1}; int n, lenss = strlen(ss); bool dfs(int x, int y, int index, int k) { // printf("start:%d %d %d %d\n", x, y, index, k); if(index >= lenss) return true; if(x < 0 || x >= n || y < 0 || y >= n) return false; if(s[x][y] != ss[index]) return false; if(dfs(x + dx[k], y + dy[k], index + 1, k)) { f[x][y] = 1; } } int main() { // 读入数据 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); memset(f, 0, sizeof(f)); cin>>n; for(int i=0;i<n;i++) for(int j=0;j<n;j++)cin>>s[i][j]; // 遍历搜索 for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) { if(s[i][j] != 'y') continue; for(int k = 0; k < 8; k++) { dfs(i,j,0,k); } } // 输出结果 for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(f[i][j]) cout<<s[i][j]; else cout<<"*"; } cout<<endl; } return 0; } ```
by yuyanggo @ 2019-03-29 00:27:36


@[yuyanggo](/space/show?uid=465) good666
by fzhfzh @ 2019-04-06 18:45:52


可能是评测系统有问题吧,或者是输出格式?
by fzhfzh @ 2019-04-06 18:46:35


|