当前位置:Gxlcms > 数据库问题 > Gym 101308DDatabase 枚举

Gym 101308DDatabase 枚举

时间:2021-07-01 10:21:17 帮助过:35人阅读

<cstdio> #include <algorithm> #include <cstring> using namespace std; const int maxn=10000+5; char s[105]; int n,m; int now_c; struct Row { int id; char col[15][105]; } row[maxn]; void shit(int index) { row[index].id=index; int i=0, k = 0, t = 0; while(s[i]!=\0) { if (s[i] == ,) { k++; t=0; i++; } row[index].col[k][t++] = s[i]; i++; } } bool cmp(Row a,Row b) { if(strcmp(a.col[now_c],b.col[now_c])<0) return true; return false; } int main() { // freopen("in.txt","r",stdin); freopen("database.in","r",stdin); freopen("database.out","w",stdout); scanf("%d%d",&n,&m); getchar(); for(int i=0; i<n; i++) { gets(s); shit(i); } for(int i=0; i<m; i++) //枚举要排序的列 { now_c=i; sort(row,row+n,cmp); for(int j=0; j<n; j++) //枚举行 { for(int k=j+1; k<n && strcmp(row[k].col[i],row[j].col[i])==0; k++) //判断相邻两行,第i列是否相等 { for(int p=i+1; p<m; p++) //枚举要判断的列 { if(strcmp(row[k].col[p],row[j].col[p])==0) { puts("NO"); printf("%d %d\n",row[j].id+1,row[k].id+1); printf("%d %d\n",i+1,p+1); return 0; } } } } } puts("YES"); return 0; }

 

Gym 101308D Database 枚举

标签:ios   bool   open   gets   turn   algorithm   stdin   span   cst   

人气教程排行