Skip to content

Instantly share code, notes, and snippets.

@fredbr
Created August 27, 2018 22:07
Show Gist options
  • Save fredbr/af1888ba0ea3591d417dba21869638c4 to your computer and use it in GitHub Desktop.
Save fredbr/af1888ba0ea3591d417dba21869638c4 to your computer and use it in GitHub Desktop.
Mancha (OBI - 2018)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
char m[maxn][maxn];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> m[i][j];
for (int i = 0; i < n; i++) {
int ini = n, fim, cnt = 0;
for (int j = 0; j < n; j++) {
if (m[i][j] == '*') {
if (ini == n) {
ini = j;
}
cnt++;
fim = j;
}
}
if (ini != n and cnt != fim-ini+1) {
cout << "N\n";
return 0;
}
}
for (int i = 0; i < n; i++) {
int ini = n, fim, cnt = 0;
for (int j = 0; j < n; j++) {
if (m[j][i] == '*') {
if (ini == n) {
ini = j;
}
cnt++;
fim = j;
}
}
if (ini != n and cnt != fim-ini+1) {
cout << "N\n";
return 0;
}
}
cout << "S\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment