版本比较
题解 P5427 【[USACO19OPEN]Left Out】
正文
增加 27 行删除 27 行
34 行未改动35363738393940414142434445464546474849505148495051525354555657555657585959606162636463646566676869706869707172737374757677787778798081823 行未改动86878889909091929293949596979798999910010110210310410510310410510610734 行未改动```cpp#include<iostream>#include<cstdio>#include<cstring>#include<vector> #include<vector>#define pii pair<int, int>using namespace std; using namespace std;
int main(){ int n; scanf("%d", &n); int n; scanf("%d", &n); if(n == 1){printf("-1"); return 0; } char c; int a[n + 1][n + 1];
char c; int a[n + 1][n + 1];
for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) { c = getchar(); while(c != 'L' && c != 'R')c = getchar(); a[i][j] = ((c == 'L') ? 0 : 1); c = getchar(); while(c != 'L' && c != 'R')c = getchar(); a[i][j] = ((c == 'L') ? 0 : 1); }
for(int i = 1; i <= n; i++) if(a[i][1]) for(int j = 1; j <= n; j++) a[i][j] ^= 1; a[i][j] ^= 1;
for(int i = 2; i <= n; i++) if(a[1][i]) for(int j = 1; j <= n; j++) a[j][i] ^= 1; //翻转 int f = 0; a[j][i] ^= 1; //翻转 int f = 0; for(int i = 2; i <= n; i++) for(int j = 2; j <= n; j++) f += a[i][j]; f += a[i][j]; //通过子矩阵和判断情况 if(f == (n - 1) * (n - 1)) { if(n == 2)printf("-1\n"); else printf("1 1\n"); return 0; if(n == 2)printf("-1\n"); else printf("1 1\n"); return 0; } else if(f == 1) { for(int i = 2; i <= n; i++)3 行未改动 else if(f == n - 1) { for(int i = 1; i <= n; i++) { int s = 0; int s = 0; for(int j = 1; j <= n; j++) s += a[i][j]; s += a[i][j]; if(s == n - 1){printf("%d %d", i, 1); return 0; } } for(int i = 1; i <= n; i++) { int s = 0; int s = 0; for(int j = 1; j <= n; j++) s += a[j][i]; s += a[j][i]; if(s == n - 1){printf("%d %d", 1, i); return 0; } } }//三种情况 printf("-1"); return 0; } printf("-1"); return 0;}```有错误请指出qwq